How to show Vietnamese characters in subjects mail .msg file Outlook (saved by C#)?

旧巷老猫 提交于 2019-12-08 13:39:42

问题


I am using this code to save a object Outlook.MailItem to .msg file.

Outlook.Application app = new Outlook.Application();
Outlook.MailItem email = app.CreateItemFromTemplate(pathMail, Type.Missing);
email.To = "temp@gmail.com"
email.Subject = txtSubject.Text;
email.Body = txtBody.Text;
email.SaveAs(pathSave, Outlook.OlSaveAsType.olMSG);

It is great working, but it have a bug. If I write Vietnamese in txtSubject, the subject in .msg file will show "?" for Vietnamese characters.
Example: "Kiểm tra font tiếng Việt" --> "Ki?m tra font ti?ng Vi?t"
In body of .msg file, Vietnamese characters still show correctly (Image )
And when I open .msg file by Notepad, I see Encoding follow:

< ?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Thank all.


回答1:


Use olMsgUnicode format instead of olMsg.



来源:https://stackoverflow.com/questions/37451220/how-to-show-vietnamese-characters-in-subjects-mail-msg-file-outlook-saved-by-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!