I have problem when get Subject of mail. Problem is: if subject is English it is can get good but if subject is vietnamese (my language) it return null;
Asked
Active
Viewed 1,483 times
2 Answers
1
string encoding = msg.HtmlBody.ContentType.Split('=')[1];
string decodedBody = Encoding.GetEncoding(encoding).GetString(Convert.FromBase64String(msg.HtmlBody.TextData));
string decodedSubject = Encoding.GetEncoding(encoding).GetString(Convert.FromBase64String(msg.Subject.Split('?')[3]));
-
This code only works for Base64 encoded strings. Quoted printable encoding can also be used, and it's quite frequent. – Pawel Lesnikowski Jul 27 '11 at 19:22
0
If you're using the old ImapX library, I invite you to upgrade to ImapX 2. It now supports automated decoding of subjects, file names and body content. The library is being constantly developed and supported. There is also sample code for all common operations.

Pavel Azanov
- 188
- 1
- 11