(10-19-2021, 12:05 AM)Robert Gilland Wrote: This works for me:
Why are you adding the attachments to both the TIdMessage and a TObjectStringsList?
In any case, you might consider using TIdMessageBuilderHtml to simplify the logic of populating the TIdMessage body, eg:
Code:
idmsg := TIdMssage.Create;
try
idmsg.Date := Now;
idmsg.FromList.EMailAddresses := FEmailReply;
idmsg.Subject := SubJect;
idmsg.Recipients.EMailAddresses := ReceiveAddr;
idMsgBldr := TIdMessageBuilderHtml.Create;
try
idMsgBldr.Html.Assign(slInfo);
for j := 0 to slFiles.Count-1 do begin
idMsgBldr.Attachments.Add(slFiles[j]);
end;
if Assigned(psInsideFiles) then begin
for j := 0 to psInsideFiles.Count-1 do
idMsgBldr.HtmlFiles.Add(psInsideFiles[j], TStringObj(psInsideFiles.Objects[j]).TheString);
end;
idMsg := idMsgBldr.FillMessage(idMsg);
finally
idMsgBldr.Free;
end;
// use idMsg as needed...
finally
idMsg.Free;
end;
Alternatively:
Code:
idmsg := nil;
try
idMsgBldr := TIdMessageBuilderHtml.Create;
try
idMsgBldr.Html.Assign(slInfo);
for j := 0 to slFiles.Count-1 do begin
idMsgBldr.Attachments.Add(slFiles[j]);
end;
if Assigned(psInsideFiles) then begin
for j := 0 to psInsideFiles.Count-1 do
idMsgBldr.HtmlFiles.Add(psInsideFiles[j], TStringObj(psInsideFiles.Objects[j]).TheString);
end;
idMsg := idMsgBldr.NewMessage;
finally
idMsgBldr.Free;
end;
idmsg.Date := Now;
idmsg.FromList.EMailAddresses := FEmailReply;
idmsg.Subject := SubJect;
idmsg.Recipients.EMailAddresses := ReceiveAddr;
// use idMsg as needed...
finally
idMsg.Free;
end;