function TMailThread.SendMail(ToAddress, Subject : String; MailText : String; ImageFiles : TStringDynArray) : Boolean;
var IdMessage: TIdMessage; lTextPart: TIdText;
idAttachment: TIdAttachment;
Stream: TStream;
Enc: TIdTextEncoding;
i : Integer;
begin
Result := False;
IdMessage := TIdMessage.Create(nil);
IdMessage.Subject := Subject;
with IdMessage do
begin
ContentType := 'multipart/related; type="text/
html"';
CharSet:= 'ISO-8859-1';
ContentTransferEncoding := 'quoted-printable';
From.Address := MailSettings.FromAddress;
From.Name := MailSettings.FromName;
Recipients.EMailAddresses := ToAddress;
end;
with TIdText.Create(IdMessage.MessageParts, nil) do
begin
Body.Text := MailText;
ContentType := 'text/
html';
CharSet := 'ISO-8859-1';
end;
for i := 0 to High(ImageFiles) do
with TIdAttachmentFile.Create(IdMessage.MessageParts, ImageFiles[i]) do
begin
ContentID := 'image' + IntToStr(i+1);
ContentType := 'image/jpeg';
end;
try
IdSMTP.Send(IdMessage);
Result := True;
finally
IdMessage.Free;
end;
end;