PatV 1 Posted March 6, 2021 Hi All, I'm using Parallel.Async to send an email, even if it's working, I would like to know if my approach is correct ; procedure TTFrmPanelPrint.SendMailParallel; var sRacine : string; sFrom,sName,sSubject,sBody : string; begin sRacine:=TPath.Combine(FReport.Directory ,FReport.FileName); sFrom := rUser(FReport.Print.Values[pspUser]^).Mail.GetMail; sName := rUser(FReport.Print.Values[pspUser]^).Name.FirstLastName; sBody :=Comment.Lines.Text; sSubject:= FFile.External; end; Parallel.Async ( Procedure(const task : IOmniTask) function AddAttach(const aRacine : string) : TStringList; var sFile : string; begin Result:=TStringList.Create; Result.Add(aRacine+cExtPdf); Result.Add(aRacine+cExtXlsx); for sFile in LBAttachments.Items do Result.Add(sFile); end; var sAttach,sTo,sBC,sCC : TSTringList; begin sAttach := AddAttach(sRacine); sTo :=TStringList.Create; sCC :=TStringList.Create; sBC :=TStringList.Create; sTo.Add(CbCommunication.Text); Task.Invoke ( procedure begin FMail.WithFrom(sFrom) .WithFromName(sName) .WithTo(sTo) .WithSubject(sSubject) .WithBody(sBody) .WithAttachments(sAttach) .WithPrcMailLog(LogAdd) .WithPrcOnDone(MailSendDone) .Send; sTo.Free; sCC.Free; sBC.Free; sAttach.Free; end ) end ); end; Thanks a lot Patrick Share this post Link to post