简体   繁体   中英

EWS Managed API 2.0 message encoding

I have a question bout the encoding of email messages when sending via EWS Managed API 2.

I haven't been able to find any clear answer to this on the MSDN pages so I'll try you guys.

When using the standard .NET SmtpClient I can set the encoding of both the body and the subject attribute (I need utf-8) - this doesn't seem to be the case when using EWS Managed API 2.

Or, is it in fact the MimeContent attribute of the EmailMessage that is used for this and if so, how do I do the same thing for the subject of the email message?

For the body - is this the correct way to do it?

EmailMessage.MimeContent = 
new MimeContent("utf-8", Encoding.UTF8.GetBytes("<body text html or plain text>"));

And then I don't set the EmailMessage.Body attribute or?

Never mind, it appears that I don't have the specify utf-8. I have now tried to set the body attribute with both text and HTML that included special characters and in both cases the result looked correct in the mail.

EmailMessage.Body = new MessageBody(BodyType.HTML, "<html content>");
EmailMessage.Body = new MessageBody(BodyType.Text, "plain text content>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM