HTML text in the body of an email (delphi code)
Posted on 2016-09-10
I use the TIdMessage component with Delphi XE2 for sending email from an application
I want the body of the email to be HTML text
So i put these lines in the Body of the TidMessage :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
<BODY> Text... </BODY>
There is also an attachement to the email I send
If I do not set the ContentType property of the TidMessage, the recipient receives an email with an attachment, but the body looks exactly like the example above
Now if I set the ContentType property of the TidMessage to 'text/html', the recipient receives an email without attachment, but with something like this in the body ;
This is a multi-part message in MIME format --60YuqVcoHk37WTm=_6Ty64BkuN4X4FCMT6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
--60YuqVcoHk37WTm=_6Ty64BkuN4X4FCMT6 Content-Type: application/octet-stream; name="TheAttachmentFileName" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="TheAttachmentFileName" Q2x1YiBkZSBCcmlkZ2UgU2FpbnQgTGFtYmVydCAtIFRvdXJub2kgZH etc etc ...
What shall I change to have the attachment correctly ... attached and the text correctly displayed ?