Hallo,
so funktioniert es jetzt:
Delphi-Quellcode:
function SendEmail(Recipient:
string;CCList:
string;sSubject:
string;Body:TStringList; Pfad:
string):boolean;
var
nAlarmnr:integer;
Attachment: TIdAttachment;
begin
idSMTP:=TidSMTP.Create;
idMessage:=TidMessage.Create;
idSMTP.Host := '
XXX.XXX.XXX.XXX';
idSMTP.Username := '
XXXXXX';
idSMTP.Password := '
XXXX';
idSMTP.Port := XX;
idMessage.From.text :='
XX@XXXXXX.de';
idMessage.Sender.text:=idMessage.From.text;
idMessage.Recipients.EMailAddresses:= Recipient;
idMessage.CCList.EMailAddresses := CCList;
idMessage.Subject:=sSubject;
idMessage.ContentType:='
multipart/*';
with TidText.Create(idMessage.MessageParts,body)
do
begin
contenttype:='
text/html';
end;
with TIdAttachmentFile.Create(idMessage.MessageParts, Pfad)
do
begin
idMessage.MessageParts.Add();
end;
try
idSMTP.Connect;
idSMTP.Send(idMessage);
idSMTP.Disconnect;
result:=True;
except on E :
Exception do
begin
if idSMTP.connected
then try idSMTP.disconnect;
except end;
result := false;
end;
end;
end;
Vielen Dank für die Hilfe