0 votes

I'm trying to send a message with a subject that contains Unicode symbols.

When I try to send such message from my Gmail account, the subject is displayed correctly and the subject header looks like this:

Subject: =?UTF-8?B?8J+OgVByZXNlbnRzIfCfjoE=?=

However, when I send such message via Mail.dll the subject gets corrupted and is displayed with question marks instead of unicode characters. The subject header looks like this:

Subject: =?utf-8?B?77+977+9UHJlc2VudHMh77+977+9?=

Is there a way to change this behavior of MailBuilder so the unicode characters in the subject stay untouched?

closed with the note: Thanks, the bugfix did it
by (200 points)
closed by

1 Answer

0 votes

Mail.dll correctly encodes all utf-8 characters. Internally Encoding.Utf8.GetBytes is used and the result is encoded using base64 or qp.

How does your code look like? Are you using correct encoding for your c# code file?

by (301k points)
edited by
Our production code uses values from database to fill the subject. We know these values are stored correctly because when we output them on a web page they are displayed the way they should (as unicode characters).

I was able to reproduce the problem with this piece of code: http://pastebin.com/QdXL3qQe

The encoding of the C# file is Unicode with BOM. It shouldn't matter though because the problem persists even if I use unicode escape sequences in string instead of the symbol like in this sample: http://pastebin.com/5H743N4D

If you decode the mime headers from both of these EMLs you'll see question marks instead of pictures.
What is the Mail.dll version you are using?
We're using version 3.0.13264.1223 judging by the assembly file properties.
You are correct, it is a bug. I was able to identify it and know how to correct it. We'll provide a fix next week.
Thanks, how will you let us know? Will you just add a comment in this thread?
Exactly. We'll add a comment here.
It has been corrected. You can download the latest version here:
https://www.limilabs.com/mail/download
...