JuV*_*cia 5 c# exchangewebservices
我有一个应用程序,使用EWS从交换机中读取电子邮件.我的问题是,获取电子邮件的HTML版本是一个电话,并获得电子邮件的TEXT版本是另一个电话.
有没有第三方控件可以在一次调用中获取两种格式?
有一些示例代码会很棒.
看看Exchange Server开发论坛上的这个帖子,我想它会回答你的问题.http://social.technet.microsoft.com/Forums/exchange/en-US/3c95b323-1ba2-4bc5-80bd-f5626707db6a/i-need-the-htmltext-and-the-plaintext-of-the-body-的-AN-项目类型?论坛= exchangesvrdevelopment
更新
我玩这个,所以我可以提供一个代码示例,事实证明你不必使用扩展属性.默认情况下,EWS在EmailMessageSchema.Body中返回HTML格式的主体 - 因此,如果您创建的属性集包含ItemSchema.TextBody和EmailMessageSchema.Body,则可以在一个Bind调用中获取这两种类型.
public static void GetEmail(ExchangeService service, ItemId ItemId)
{
PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.TextBody, EmailMessageSchema.Body);
EmailMessage message = EmailMessage.Bind(service, ItemId, propSet);
}
Run Code Online (Sandbox Code Playgroud)
这会产生以下XML请求:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:GetItem>
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:TextBody" />
<t:FieldURI FieldURI="item:Body" />
</t:AdditionalProperties>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="AAMkADE4..." />
</m:ItemIds>
</m:GetItem>
</soap:Body>
Run Code Online (Sandbox Code Playgroud)
以下回复:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="878" MinorBuildNumber="11" Version="V2_10" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId Id="AAMkADE4..." ChangeKey="CQAAABYAAAApjGm7TnMWQ5TzjbhziLL0AAGTja3C" />
<t:Body BodyType="HTML" IsTruncated="false"><!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
(Removed the rest of my HTML body)
</t:Body>
<t:TextBody BodyType="Text" IsTruncated="false">
(Removed my text body)
</t:TextBody>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!咪咪
| 归档时间: |
|
| 查看次数: |
13937 次 |
| 最近记录: |