procedure TFrmMailVerkehr.SendeEmail(aAnmelden: Boolean);
var
pMailAdresse:
string;
pBCCListe:
string;
pErrMsg:
string;
pAnz: SmallInt;
pEText:
string;
AMessage: TIdMessage;
ASMTP: TIdSMTP;
I: Integer;
AStream: TMemoryStream;
AMessageBuilder: TIdMessageBuilderHtml;
procedure CheckMail;
var
I: Integer;
APart: TIdMessagePart;
AFileName:
string;
s:
string;
begin
// ContentDisposition erweitern, sonst werden InlinImages
// nicht auf Android angezeigt...
AMessage.MessageParts.CountParts;
for I := 0
to AMessage.MessageParts.Count - 1
do
begin
APart := AMessage.MessageParts[I];
if (APart.ContentDisposition = '
inline')
then
begin
s := APart.Headers.Values['
Content-ID'];
if s <> '
'
then
begin
AFileName := Copy(s, 2, Length(s) - 2);
APart.Headers.Values['
Content-Disposition'] := '
inline; filename="' +
AFileName + '
"';
end;
end;
end;
end;
function ServerAnmelden: Boolean;
begin
Result := True;
ASMTP := TIdSMTP.Create(Self);
if ASMTP.Connected
then
ASMTP.Disconnect(True);
try
ASMTP.AuthType := satDefault;
ASMTP.UserName := MailUserName;
ASMTP.Password := MailPassWort;
ASMTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(ASMTP);
// ASMTP.UseTLS := utNoTLSSupport;
ASMTP.UseTLS := utUseImplicitTLS;
if (MailPort = 465)
or (MailPort = 587)
then
ASMTP.UseTLS := utUseExplicitTLS
// utNoTLSSupport
else
ASMTP.UseTLS := utUseImplicitTLS;
ASMTP.ManagedIOHandler := True;
ASMTP.Host := MailHostName;
ASMTP.Port := MailPort;
ASMTP.Connect;
except
on E:
Exception do
begin
pErrMsg := e.
Message;
if ASMTP.LastCmdResult.Code <> '
'
then
pErrMsg := ASMTP.LastCmdResult.Text.Text
+ sLineBreak + '
--'
+ sLineBreak + pErrMsg;
ASMTP.Free;
Result := False;
end;
end;
......