procedure sendNewsLetter(an: Tstringlist; att1: Tstrings; Nachricht: Trichedit;
vonMail, Betreff, Priority, CT, SMTPServer, SMTPUsername, SMTPPass:
String;
SMTPPort, SmtpAuthType: integer; PopServer, PopUser, PopPass:
String; PopPort: integer);
var
IdMsgSend: TidMessage;
SMTP: TidSmtp;
POP: TidPop3;
i: integer;
s:
string;
begin
IdMsgSend := TidMessage.Create(
nil);
SMTP := TidSmtp.Create(
nil);
POP := TidPop3.create(
nil);
IdMsgSend.Clear;
// Plain Text
with TIdText.Create(IdMsgSend.MessageParts,
nil)
do
begin
ContentType := '
text/plain';
Body.Text := Nachricht.Text;
end;
// HTML Part
with TIdText.Create(IdMsgSend.MessageParts,
nil)
do
begin
ContentType := '
text/html';
Body.Text := RtfToHtml('
MetaHead', Nachricht);
//Benötigt funktion um RTF zu HTML umzuwandeln
end;
with IdMsgSend
do
begin
ContentType := CT;
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 := '
';
end;
if att1.Count >= 1
then
begin
for i := 0
to att1.Count - 1
do
begin
TIdAttachment.Create(IdMsgSend.MessageParts, att1.Strings[i] );
end;
end;
IdMsgSend.ContentType := CT ;
case SmtpAuthType
of
0:
SMTP.AuthenticationType := atNone;
//Normal
1:
SMTP.AuthenticationType := atLogin;
//SMTPAuth
2:
begin //AfterPop
SMTP.AuthenticationType := atNone;
POP.Host := POPServer;
POP.Username := POPUser;
POP.Password := POPPass;
POP.Port := POPPort;
POP.Connect(5);
POP.Disconnect;
end;
3:
begin //afterPop+SMTPAuth
SMTP.AuthenticationType := atLogin;
POP.Host := POPServer;
POP.Username := POPUser;
POP.Password := POPPass;
POP.Port := POPPort;
POP.Connect(5);
POP.Disconnect;
end;
end;
SMTP.Username := SMTPUsername;
SMTP.Password := SMTPPass;
SMTP.Host := SMTPServer;
SMTP.Port := SMTPPort;
SMTP.Connect;
ShowMessage(IntToStr(IdMsgSend.MessageParts.Count));
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
IdMsgSend.free;
SMTP.free;
POP.free;
end;