[...]
(* SMTP-Komponente initialisieren *)
idSMTPFinal := TIdSMTP.Create(
nil);
idSMTPFinal.AuthType := satDefault;
idSMTPFinal.Host := '
mail.gmx.net';
idSMTPFinal.Password := '
xxxxxxxxxxxxx';
idSMTPFinal.Port := 25;
idSMTPFinal.Username := '
xxxxxxxxxxxxxxxxxxx';
idSMTPFinal.UseTLS := utNoTLSSupport;
idSMTPFinal.UseVerp := False;
(* Nachricht erstellen *)
idMessageFinal := TIdMessage.Create(
nil);
idMessageFinal.ContentType := '
multipart/mixed';
idMessageFinal.ContentTransferEncoding := '
8 bit';
idMessageFinal.Encoding := meMIME;
idMessageFinal.AttachmentEncoding := '
MIME';
idAttachment := TIdAttachmentFile.Create(idMessageFinal.MessageParts, '
d:\test.pdf');
idAttachment.ContentType := '
application/pdf';
IdMessageFinal.From.Address := '
xxxxxxxxxxxxxxxxxxxxx';
IdMessageFinal.From.
Name := '
xxxxxxxxxxxxxxxxx';
idMessageFinal.Subject := '
Testnachricht';
idMessageFinal.Body.Add('
Das ist die Nachricht.......');
idMessageFinal.Recipients.Add.Address := '
xxxxxxxxxxxxxxxx';
StatusBar.Panels[0].Text := '
Versenden der eMail, bitte warten...';
Application.ProcessMessages;
try
IdSMTPFinal.Connect;
IdSMTPFinal.Send(idMessageFinal);
IdSMTPFinal.Disconnect();
idAttachment.Free;
idMessageFinal.Free;
idSMTPFinal.Free;
except
if IdSMTPFinal.Connected
then
IdSMTPFinal.Disconnect();
idAttachment.Free;
idMessageFinal.Free;
idSMTPFinal.Free;
end;
[...]