interface
uses
SysUtils, Classes, IpMsg, IpSock, IpUtils, IpSmtp;
function Send_Mail(MailHost, Absender, Empfaenger, Betreff, MailText, Anhang :
string) : boolean;
implementation
///////////////////////////////////////////////////////////////////////////////////////////////////
// public
///////////////////////////////////////////////////////////////////////////////////////////////////
function Send_Mail;
var
SmtpClient : TIpSmtpClient;
Disclaimer : TStringList;
i : integer;
begin
//setup SMTP
SmtpClient := TIpSmtpClient.Create(
nil);
SmtpClient.
Message.NewMessage;
SmtpClient.
Message.MailTo.Add(Empfaenger);
SmtpClient.
Message.From := Absender;
SmtpClient.
Message.Subject := Betreff;
SmtpClient.
Message.ContentType := '
multipart';
SmtpClient.
Message.ContentSubtype := '
mixed';
Disclaimer := TStringList.Create;
Disclaimer.Add(MailText);
SmtpClient.
Message.EncodeBodyStrings(Disclaimer, '
');
Disclaimer.Free;
SmtpClient.AttachmentList.Add(Anhang);
//send mail
SmtpClient.SendMail(MailHost, false);
// <<<<<<<<< hier wird nicht Connected
for i := 0
to 999
do begin
Sleep(100);
Result := SmtpClient.Connected;
if Result
then begin
SmtpClient.Quit;
Break;
end
else WriteLn(SmtpClient.StateToStr(SmtpClient.State));
end;
if not Result
then WriteLn(SmtpClient.StateToStr(SmtpClient.State));
end;