I received a complaint from a customer saying they receive emails sent with a xojo web app as unreadable characters.
The mail.BodyPlainText contains characters such as the euro sign, which arrives on certain email clients as:
On my iPhone and Mac Mail, it arrives as intended; the Euro sign.
Should I set a custom header and if so, what should it contain to avoid some email clients showing it incorrectly?
I know HTML text would not have this issue, but I’d prefer to keep the email plain text.
headers of the email declare it as being UTF-8?
Our CurlEMailMBS class does it automatically.
@Christian Schmitz :Thanks Christian, I’m currently using the SMTPSecureSocket so I’d prefer to just add the right header definition instead of having to re-write using CurlEmailMBS.
I use :
MailMessage.Subject = "=?UTF-8?B?" + EncodeBase64(DefineEncoding(theSubject, Encodings.UTF8)) + "?="
MailMessage.BodyPlainText = DefineEncoding( theText, Encodings.UTF8)
MailMessage.BodyHTML = DefineEncoding( theHTML, Encodings.UTF8)
MailMessage.Headers.AppendHeader("Content-type", "multipart/alternative; charset=UTF-8")
to send the mail as UTF8
for now it seems to work correctly on many mac and windows mail clients.
Thank you Jean-Yves. But I don’t understand why you DefineEncoding, it would be convert as the encoding of thetext is supposed to be known.
I use one of the 2 solutions :
MessMail.Subject = "=?UTF-8?B?" + EncodeBase64(thetext.ConvertEncoding(DefAppEncod)) + "?=" ' Encodings.UTF8
MessMail.Subject = "=?UTF-8?Q?" + EncodeQuotedPrintable(thetext.ConvertEncoding(DefAppEncod)) + "?=" ' Encodings.UTF8
yes it seems they are not mandatory here , it is just to be very sure of the encoding we send into the mail message !