procedure SendenThreadExecute;
var tp: PThreadParams;
Thread: THandle;
ExitCode: Cardinal;
ec: DWORD;
ThreadID: Cardinal;
begin
if Length(MailForm.SubjectEdit.Text) >= 3
then
begin
New(
tp);
with Mailform.IdMsgSend
do
begin
Body.Assign(Mailform.ContentMemo.Lines);
From.Text := UserEmail;
ReplyTo.EMailAddresses := UserEmail;
Recipients.EMailAddresses := ReceiverEmail;
{ To: header }
Subject := Mailform.SubjectEdit.Text;
{ Subject: header }
Priority := TIdMessagePriority(Mailform.PrioComboBox.ItemIndex);
{ Message Priority }
end;
// with
Mailform.SMTP.Username := SmtpServerUser;
Mailform.SMTP.Password := SmtpServerPassword;
{Allgemeine Einstellungen}
Mailform.SMTP.Host := SmtpServerName;
Mailform.SMTP.Port := SmtpServerPort;
tp.sttemp := Mailform.EingangStatusBar.Panels[1].Text;
Mailform.Label1.Caption :=
tp^.sttemp;
tp.msgSend := Mailform.IdMsgSend;
Thread := BeginThread(
nil, 0, @SendenThreadFunction,
tp, 0, ThreadID);
// Auf Beendigung des Threads warten.
//WaitForSingleObject(Thread, INFINITE);
CloseHandle(Thread);
end //if
else
begin
MessageDlg('
Bitte geben Sie einen Betreff ein.', mtWarning ,[mbOK],0);
end;
end;
function SendenThreadFunction(
tp: PThreadParams): Integer;
var msgSend: TIdMessage;
sttemp:
String;
begin
sttemp := PThreadParams(
tp)^.sttemp;
msgSend := PThreadParams(
tp)^.msgSend;
{Mail verschicken}
Mailform.ShowStatus('
Verbindung mit Postausgangsserver wird hergestellt...');
Mailform.SMTP.Connect;
try
Mailform.SMTP.Send(msgSend);
Mailform.ShowStatus('
Nachricht wird gesendet');
finally
Mailform.SMTP.Disconnect;
Mailform.ShowStatus(sttemp);
Mailform.MailPb.Visible := False;
Mailform.MailPb.Position := Mailform.MailPb.Max;
Mailform.EingangStatusBar.Panels[0].Text := '
Senden erfolgreich';
Dispose(
tp);
end;
// try