Reputation: 21
I'm making outlook vsto plugin for sending email, and I have a problem with encoding. If I send only english characters in message it is encoded as ascii, and in outlook sender name doesn't display serbian latin characters. If I send serbian latin characters in message it is encoded as iso-8859-2, and in outlook sender name is fine.
Outlook.Application _app = new Outlook.Application();
Outlook.MailItem mail = _app.CreateItem(Outlook.OlItemType.olMailItem);
mail.To = txtTo.Text;
mail.Subject = "Promena adrese";
mail.Body = txtPackageNum.Text + " " + txtNewAddress.Text;
mail.Send();
Here's what it looks like in inbox
How can I fix this? I would like encoding to be utf-8 no matter what is sent in message
Upvotes: 1
Views: 810
Reputation: 337
please try below code,
mail.BodyEncoding = System.Text.Encoding.UTF8;
This will encode your message in utf8 format. if you also want to encode subject then you can use
mail.SubjectEncoding = System.Text.Encoding.UTF8;
For more information you can also visit msdn page MSDN link
Upvotes: 1