Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Wie kann ich mit procedure ? (https://www.delphipraxis.net/5829-wie-kann-ich-mit-procedure.html)

bundy 20. Jun 2003 13:06


Wie kann ich mit procedure ?
 
hallo leute eine dumme Frage.

ich hab einen mailclient geschrieben.
Wo und wie muss ich die procedure im hauptform eintragen, so das
ich von anderen Formularen zugreifen kann ?

Danke im voraus.

:coder: :coder: :coder: :coder: :coder: :coder: :coder:
Delphi-Quellcode:
procedure sendmail (an,Text,Absender:string) ;
Var ini:TIniFile;
begin
//-------CONFIG HOST-------
ini := TiniFile.Create ('.\econfig.ini');
with ini do
begin
Hauptform.IdSMTP1.Host:=ReadString('E-Mail', 'SMTP','') ;


//--------------------------
Hauptform.IdMessage1.Clear;

  // Plain Text
{ with TIdText.Create(Form1.IdMessage1.MessageParts, nil) do
  begin
    ContentType := 'text/plain';
    Body.Text := 'Das sieht der Text-Viewer Betrachter';

  end;    }

  // HTML Part
 { with TIdText.Create(Form1.IdMessage1.MessageParts, nil) do
  begin
    ContentType := 'text/html';
    Body.Text := Text;



  end;  }


  Hauptform.IdMessage1.ContentType := 'text';

  Hauptform.IdMessage1.Body.Text:=Text+#13+ReadString('E-Mail','Betreff','');;
  Hauptform.IdMessage1.From.Address :=ReadString('E-Mail','von','');
  Hauptform.IdMessage1.From.Name := ReadString('E-Mail','Absender','');
  Hauptform.IdMessage1.Subject := ReadString('E-Mail','Betreff','');
  Hauptform.IdMessage1.Recipients.Add.Address := an;

  ShowMessage(IntToStr(Hauptform.IdMessage1.MessageParts.Count));

  Hauptform.IdSMTP1.Connect;
  try
    Hauptform.IdSMTP1.Send(Hauptform.IdMessage1);
  finally
    Hauptform.IdSMTP1.Disconnect;
  end;
end;
ini.Free;

end;
[Edit=Sakura]Delphi-TAGs eingefügt.[/Edit]

Christian Seehase 20. Jun 2003 13:22

Moin Bundy,

entweder Du bindest das als Methode des Hauptformulares ein, oder Du stellst es im Interface Abschnitt als Prozedur zur Verfügung.

In beiden Fällen musst Du natürlich die Unit mit der Prozedur auch in den anderen Units die darauf zugreifen sollen einbinden.


Delphi-Quellcode:
type
  THauptform = class(TForm)
  //...
  procedure SendMail(....);
  //...
  end;

implementation

//...

procedure THauptform.SendMail(....);
begin
end;

// oder

var
  Hauptform : THauptform;

procedure SendMail(...);

implementation

bundy 20. Jun 2003 13:32

Super funzt danke :love:

:bounce2: :bounce2: :bounce2: :bounce2: :bounce2:


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz