Source
procedure sendNewsLetter(an: Tstringlist; att, Text: Tstrings;
vonMail, Betreff, Priority, CT, SMTPServer, SMTPUsername, SMTPPass:
string;
SMTPPort, SmtpAuthType: integer);
var IdMsgSend: TidMessage;
SMTP: TidSmtp; i: integer; s:
string;
begin
IdMsgSend := TidMessage.Create(
nil);
SMTP := TidSmtp.Create(
nil);
with IdMsgSend
do
begin
ContentTyp := CT;
Body.Assign(text);
From.Text := vonMail;
ReplyTo.EMailAddresses := vonMail;
Subject := Betreff;
Priority := Priority;
s := '
';
for i := 0
to an.Count - 1
do
begin
s := s + BccList.EMailAddresses + an.Strings[i] + '
;'
end;
BccList.EMailAddresses := s;
ReceiptRecipient.Text := vonMail;
end;
if att.Count >= 1
then
begin
for i := 0
to att.Count - 1
do
begin
TIdAttachment.Create(IdMsgSend.MessageParts, att.Strings[i]);
end;
end;
case SmtpAuthType
of
0:
SMTP.AuthenticationType := atNone;
1:
SMTP.AuthenticationType := atLogin;
end;
SMTP.Username := SMTPUsername;
SMTP.Password := SMTPPass;
SMTP.Host := SMTPServer;
SMTP.Port := SMTPPort;
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
IdMsgSend.free;
SMTP.free;
end;