procedure TFrmMailMain.AusWertSend(An, Nachricht, vonMail, Betreff, Priority, CT, SMTPServer, SMTPUsername, SMTPPass:
String;
SMTPAuth, SMTPPort : integer);
var
IdMsgSend: TidMessage;
SMTP: TidSmtp;
POP: TidPop3;
i: integer;
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;
end;
// HTML Part
with TIdText.Create(IdMsgSend.MessageParts,
nil)
do
begin
ContentType := '
text/html';
Body.Text := '
Dateien\MailVorlage.html';
end;
with IdMsgSend
do
begin
ContentType := CT;
From.Text := vonMail;
ReplyTo.EMailAddresses := vonMail;
Subject := Betreff;
Priority := Priority;
BccList.EMailAddresses := An;
ReceiptRecipient.Text := '
';
end;
IdMsgSend.ContentType := CT;
case SMTPAuth
of
0 :
SMTP.AuthType := atNone;
1 :
SMTP.AuthType := atDefault;
end;
{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; }
SMTPUsername := SMTPUsername;
SMTP.Password := SMTPPass;
SMTP.Host := SMTPServer;
SMTP.Port := SMTPPort;
SMTP.Connect;
MemoLog.Lines.Add(IntToStr(IdMsgSend.MessageParts.Count));
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
IdMsgSend.free;
SMTP.free;
end;