procedure TForm1.AusWertSend(an, Nachricht, vonMail, Betreff, Priority, CT, SMTPServer, SMTPUsername, SMTPPass:
String;
SMTPPort : integer);
var
IdMsgSend: TidMessage;
SMTP: TidSmtp;
POP: TidPop3;
i: integer;
s:
string;
begin
IdMsgSend := TidMessage.Create(
nil);
SMTP := TidSmtp.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;
s := '
';
BccList.EMailAddresses := an;
ReceiptRecipient.Text := '
';
end;
SMTP.AuthType := atDefault;
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;
end;
procedure TForm1.btnSendenClick(Sender: TObject);
begin
AusWertSend(EditAdressen.Text, MemoText.Text,'
Andi_S75@hotmail.de',EditBetreff.Text, '
mpnormal','
BlaBlaBla',
EditSMTP.Text,EditBenutzer.Text, EditKennwort.Text,25);
end;