function TMailer.SendIndyMail: Boolean;
var
i: Integer;
Email: TIdEMailAddressItem;
bodyText: TStringList;
begin
FSMTP.Host := FSMTPHost;
FSMTP.Port := FMailPort;
FSMTP.Username := FSMTPLogin;
FSMTP.Password := FSMTPPassword;
// *** setup mail message ***
FMailMessage.From.Address := FSender;
FMailMessage.Subject := UTF8Encode(FSubject);
Email := FMailMessage.Recipients.Add;
Email.Address := "max@mustermann.de";
FMailMessage.OnInitializeISO := IdMessage_InitializeISO;
FMailMessage.CharSet := 'utf-8';
FMailMessage.ContentTransferEncoding := '8bit';
// attachment
if AttachmentsExists then begin
FMailMessage.ContentType := 'multipart/mixed';
with TIdText.Create(FMailMessage.MessageParts) do begin
Body.Text := FBody;
CharSet:= 'utf-8';
ContentType := 'text/plain'
end;
for I := 0 to FAttList.Count - 1 do begin
with TIdAttachmentFile.Create(FMailMessage.MessageParts, FAttList[i]) do begin
FileName := ExtractFileName(FAttList[i]);
ContentType := FMimeTable.GetFileMIMEType(FileName);
end;
end;
end
// *** send mail ***
try
try
FSMTP.Connect;
FSMTP.Send(FMailMessage);
Result := True;
except on E:
Exception do
if not FShutUpOnErr then
MessageDlg('TMailer.SendIndyMail: ' + E.Message, mtError, [mbOK], 0);
end;
finally
if FSMTP.Connected then
FSMTP.Disconnect;
end;
end;