EWS 正文纯文本 [英] EWS body plain text

查看:21
本文介绍了EWS 正文纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 EWS 来获取交换电子邮件,但是如何从电子邮件正文中获取纯文本,而没有 html?
现在我用这个:

I use EWS to get exchange emails, but how can i get plain text from email body, without html?
Now i use this:

EmailMessage item = (EmailMessage)outbox.Items[i];
item.Load();
item.Body.Text

推荐答案

在您的项目的 PropertySet 中,您需要将 RequestedBodyType 设置为 BodyType.Text.举个例子:

In the PropertySet of your item you need to set the RequestedBodyType to BodyType.Text. Here's an example:

PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
itempropertyset.RequestedBodyType = BodyType.Text;
ItemView itemview = new ItemView(1000);
itemview.PropertySet = itempropertyset;

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, "subject:TODO", itemview);
Item item = findResults.FirstOrDefault();
item.Load(itempropertyset);
Console.WriteLine(item.Body);

这篇关于EWS 正文纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆