EWS电子邮件的base64 img标签已编码

时间:2016-06-23 14:42:56

标签: c# exchangewebservices

背景背景:

我正在使用EWS托管API 2.0连接到客户Outlook邮箱并将其电子邮件处理到我的应用程序中。我无法控制客户发送的电子邮件类型,但部分处理是维护正在发送的附件和嵌入图像。

我的问题:

其中一位用户发送了带有base64图像的HTML类型电子邮件,作为其签名的一部分。 Exchange Api获取HTML编码的电子邮件的正文和部分正文,base64图像也被编码(将'+'符号转换为'+'),这现在破坏了我的应用程序。

问题:有没有办法在不编码base64图像的情况下检索电子邮件正文?作为一种解决方法,现在我正在做一个字符串替换'& #43;”到'+'。

这是我用来获取电子邮件正文的代码的一部分;我正在使用的程序集:Microsoft.Exchange.WebServices Version = 15.0.0.0

var service = new ExchangeService(Exchange2010_SP2);
// rest of creating the service

var singleEmailView = new ItemView(1);
SearchFilter unreadEmailsFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
var emailResults = service.FindItems(WellKnownFolderName.Inbox, unreadEmailsFilter, singleEmailView);

if (emailResults.Items.Any())
    {
        var firstItem = emailResults.Items.First();
        var email = firstItem as EmailMessage;
        email.Load();

        var propertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent, EmailMessageSchema.IsRead);
        service.LoadPropertiesForItems(new List<Item> { firstItem }, propertySet);

        var  body = firstItem.Body;
    }

执行email.Body或firstItem.Body会重复使用相同的HTML。

这是一个带有编码的base64图像的电子邮件示例 - 请参阅'&amp; #43;”在img src:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<b>HIIIIIIIIIIIIIIIIIIIIIII <b><img src="data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P&#43;goOXMv8&#43;fhw/v739/f&#43;8PD98fH/8mJl&#43;fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj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Q1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg&#43;kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS&#43;0pCZbEhAAOw==">
</b></b>
</body>
</html>

0 个答案:

没有答案