type
TForm1 =
class( TForm )
Button1 : TButton;
sdbMemo1 : TMemo;
ListBox1 : TListBox;
procedure Button1Click( Sender : TObject );
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1 : TForm1;
implementation
{$R *.dfm}
uses
smtpsend, mimemess,
// ararat synapse units
DMIMKER;
procedure TForm1.Button1Click( Sender : TObject );
var
LMail : TMimeMess;
LSmtp : TSMTPSend;
begin
fDMIMKER.ZQMailverbindung.Open;
try
fDMIMKER.ZQAdressenmailbcc.Open;
try
LSmtp := TSMTPSend.Create;
try
LSmtp.TargetHost := fDMIMKER.ZQMailverbindungmailausgangsserver.AsString;
LSmtp.TargetPort := '
25';
LSmtp.UserName := fDMIMKER.ZQMailverbindungmailmailadresse.AsString;
LSmtp.Password := fDMIMKER.ZQMailverbindungmailpasswort.AsString;
LMail := TMimeMess.Create;
try
// Header
LMail.Header.From := fDMIMKER.ZQMailverbindungmailmailadresse.AsString;
LMail.Header.Subject := '
Test-Mail';
LMail.Header.Priority := MP_normal;
// Body
LMail.AddPartHTML( sdbMemo1.Lines,
nil );
// Mail codieren
LMail.EncodeMessage;
if not LSmtp.Login
then
raise Exception.CreateFmt( '
SMTP.Login > %s', [LSmtp.ResultString] );
try
if not LSmtp.MailFrom( fDMIMKER.ZQMailverbindungmailmailadresse.AsString, 0 )
then
raise Exception.CreateFmt( '
SMTP.MailFrom > %s', [LSmtp.ResultString] );
fDMIMKER.ZQAdressenmailbcc.First;
while not fDMIMKER.ZQAdressenmailbcc.Eof
do
begin
if not LSmtp.MailTo( fDMIMKER.ZQAdressenmailbccadrmailbccempfaenger.AsString )
then
// fehlerhafte Mailadressen werden in eine Listbox ausgegeben
ListBox1.Items.Add( fDMIMKER.ZQAdressenmailbccadrmailbccempfaenger.AsString + '
> ' + LSmtp.ResultString );
fDMIMKER.ZQAdressenmailbcc.Next;
end;
if not LSmtp.MailData( LMail.Lines )
then
raise Exception.CreateFmt( '
SMTP.MailData > %s', [LSmtp.ResultString] );
finally
if not LSmtp.Logout
then
raise Exception.CreateFmt( '
SMTP.Logout > %s', [LSmtp.ResultString] );
end;
finally
LMail.Free;
end;
finally
LSmtp.Free;
end;
finally
fDMIMKER.ZQAdressenmailbcc.Close;
end;
finally
fDMIMKER.ZQMailverbindung.Close;
end;
end;
end.