2
votes

Using Delphi 6 I used the following line to append an email to the sent folder using IMAP:

if IMAPClient.Connected then begin
  IMAPClient.AppendMsg(EMAIL_SENT_FOLDER, TheMessage, TheMessage.Headers, [mfSeen]);
end;

If the email had attachments like a PDF only the body text would be saved and that was OK. The sender, recipient and subject were also normal as expected.

Using the same line of code in Delphi XE2, Indy 10 that ships with it and with an email that has an attachment like a PDF gets me an email in the sent folder with no subject, no sender, no recipient and the email body is base64 encoded gibberish.

This is a multi-part message in MIME format

--IstrI1aZj8jaD7S1JQXJK8dreduqQL=_Kv Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

test email body with attachment

--IstrI1aZj8jaD7S1JQXJK8dreduqQL=_Kv Content-Type: application/pdf; name="87122F343A2A49E48B22BD24376524FC.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="87122F343A2A49E48B22BD24376524FC.pdf"

JVBERi0xLjQNCiXi48/TDQoxMSAwIG9iag0KPDwNCi9UeXBlL0Fubm90L0JvcmRlciBbXS9IL0kv - base 64 stuff removed -

Edit - actually ANY email I append to the sent folder does not have a subject, sender, nor recipient. If there are no attachments the body is mostly OK but there is an errant period two lines after the body.

email body test

.

The real issue here is the lack of sender, subject, or recipient in ANY email appended to the sent folder using IMAP.

It seems to me I need to be doing something different with the newer Indy component but I cannot seem to figure out what the heck I need to do.

Any advice is appreciated.

Cheers! TJ

1
You don't have to re-include the headers if you are going to use the same message headers. Call the overloaded: IMAPClient.AppendMsg(EMAIL_SENT_FOLDER, TheMessage, [mfSeen]);jachguate
Maybe you want to read this Remy's response. Put attention to the NoEncode/NoDecode mentioned hack, as it may be the solution to your problem.jachguate

1 Answers

1
votes

Change "TheMessage.Headers" to "TheMessage.LastGeneratedHeaders".

Subject, and recipients will be there. Your attachments will still be in Base64. I don't know the fix for that.