简体   繁体   English

EWS托管API 2.0消息编码

[英]EWS Managed API 2.0 message encoding

I have a question bout the encoding of email messages when sending via EWS Managed API 2. 通过EWS托管API 2发送电子邮件时,我有一个关于电子邮件编码的问题。

I haven't been able to find any clear answer to this on the MSDN pages so I'll try you guys. 我还没有在MSDN页面上找到任何明确的答案,所以我将尝试你们。

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. 使用标准.NET SmtpClient时,我可以设置正文和主题属性的编码(我需要utf-8)-使用EWS托管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? 或者,实际上是为此使用的EmailMessage的MimeContent属性,如果是这样,我如何对电子邮件的主题执行相同的操作?

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? 然后我没有设置EmailMessage.Body属性或?

Never mind, it appears that I don't have the specify utf-8. 没关系,看来我没有指定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. 我现在尝试使用包含特殊字符的文本和HTML设置body属性,在两种情况下,结果在邮件中看起来都是正确的。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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