I'm facing a problem with the EMailMessage class. Trying to send a plain text OR HTML message works great, even with custom headers for content type and content transfer encoding, e.g. I'm using this for plain text mails:

And later to generate the body: Mail.BodyPlainText = EncodeBase64(ReplaceLineEndings(BodyText,EndOfLine.UNIX))Note: Replacing the line endings is required for any reason, otherwise some mail clients show the entire text as a very, very long line. When just using plain text, it is not required to do this. Any ideas why this happens ?

No additional headers are used when sending HTML mails, just Mail.BodyHTML = TABodyHTML.Text to create the message (TABodyHTML as TextArea).

However when trying to send a message that contains both, EMailMessage.TextBody and EMailMessage.HTMLBody parts, any additional headers I add myself to specify the encoding fail to work.

I see the main problem that it is impossible for me to adjust the content transfer encoding per message part (so I would use no special settings for HTML but above ones for plain text). Whatever I tried, my headers are overwritten by RB and replaced with standard ones working only with ASCII charset in a reliable way (Apple Mail works, but Thunderbird shows strange characters for German umlauts and other Unicode chars).

What have I missed ? Is there a solution to my problem ? Any notes and comments are highly appreciated (but please, no solutions involving third party plugins or classes, if possible).

Well, your way solving this brought me to the idea to read the EMailMessage.Source and do a RegEx-driven search for the wrong content-type and content-transfer-encoding entries to replace them with the correct values.

But although the language reference says that EMailMessage.Source can be used to get OR set the source of an e-mail message, it appears that it is read-only, because while my RegEx-replacement works, the message's source is kept untouched. Or do you see a mistake in my example ?

Your code looks fine to me. Yes, we do build the entire email from scratch plus we have our own custom classes which we use for POP, IMAP and SMTP. These are based off the SSLSocket so we are not dependent on the EMailMessage class and the RS POP3 and SMTP socket classes.

Yesterday, I gave it another attempt, but unfortunately I failed. Here is what I did:

I tried to read in the EMailMessage.Source into a string variable, adjusting the content type and encoding, then destroying the current EMailMessage object, initialize a new one and setting the source of this object with the previously stored one.

While anything seemed to work at first glance, RB does re-create the e-mail before sending (even a new boundary value was set), so any modifications I made were overwritten.