try
MailSmtp.Username := edtMailUser.Text;
// name@domain
MailSmtp.Password := edtMailPwd.Text;
// pwd von name@domain
MailSmtp.Host := edtMailServer.Text;
MailSmtp.Port := StrToInt(edtMailPort.Text);
MailMessage.Priority := mpNormal;
MailMessage.From.Address := edtMailFromAdr.Text;
// Absender-Mail-Adresse
MailMessage.Recipients.EMailAddresses := edtRecipients.Text;
MailMessage.Subject := edtSubject.Text;
MailMessage.Body.Add(edtBody.Text);
MailMessage.MessageParts.Clear;
// <<== die Lösung allen Übels!
if edtAttach.Text <> '
'
then
Anhang := TidAttachmentFile.Create(MailMessage.MessageParts, edtAttach.Text);
if edtAttach2.Text <> '
'
then
Anhang := TidAttachmentFile.Create(MailMessage.MessageParts, edtAttach2.Text);
MailSmtp.Connect;
MailSmtp.Send(MailMessage);
MailSmtp.Disconnect(true);
except
on E :
Exception do
begin
Showmessage('
Fehler: ' + E.
Message);
end;
end;