IdMsg := TIdMessage.Create(
nil);
try
IdMsg.Subject := Subject;
for idx := 0
to Addresses.Count - 1
do
IdMsg.Recipients.Add.Address := Addresses[idx];
IdMsg.ContentType := '
multipart/mixed; charset=UTF-8;';
SL := TStringList.Create;
try
SL.Add('
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
SL.Add('
<meta http-equiv="Content-Type" content="text/html; charset="UTF-8" />');
SL.Add('
<html><head>');
SL.Add(Format('
<title>%s</title>', ['
Title']));
SL.Add('
</head><body>');
SL.Add('
<div>' + Replace(BodyText, sLineBreak, '
<br />', [rfReplaceAll, rfIgnoreCase]) + '
</div>');
SL.Add('
</body></html>');
with TIdText.Create(IdMsg.MessageParts, SL)
do begin
ContentType := '
text/html';
CharSet := '
UTF-8';
end;
for idx := 0
to Length(Attachments) - 1
do
with TIdAttachmentFile.Create(IdMsg.MessageParts, Attachments[idx])
do
ContentID := Format('
%d_attach_%s', [idx, ContentIdgenerate]);
finally
SL.Free;
end;
//Wichtig ist dabei einzig und allein der X-Header (damit es als eine neue, zu sendende EMail verarbeitet wird): X-Unset
IdMsg.Headers.Add('
X-Unsent: 1');
IdMsg.SaveToFile(fileName);
finally
IdMsg.Free;
end;
ShellExecute(Self.Handle,
nil, PChar(fileName),
nil,
nil, 0);