问题
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