c# – Exchange Server不支持所请求的版本
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – Exchange Server不支持所请求的版本,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2500字,纯文字阅读大概需要4分钟。
内容图文
![c# – Exchange Server不支持所请求的版本](/upload/InfoBanner/zyjiaocheng/810/a58b8711d87f4762bd07dbc288920a35.jpg)
我得到此错误,因为FindItemsResult与我使用的交换版本不兼容,这是2013年.
Exchange Server doesn't support the requested version.
我的代码:
SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
FindItemsResults<Item> items = service.FindItems(WellKnownFolderName.Inbox, sf, new ItemView(10));
foreach (Item item in items.Items)
{
PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.TextBody);
EmailMessage email = EmailMessage.Bind(service, item.Id, propSet);
Program.SearchItems(email);
}
我可以将其更改为Exchange 2010但我在TextBody中收到错误,因为这仅适用于Exchange 2013及更高版本.
有没有办法转换可以在Exchange 2013中工作的代码?
解决方法:
您需要显示更多使用的代码,因为您的问题没有意义. ItemSchema.TextBody已添加到Exchange 2013中,因此只要您运行Exchange 2013并且您已正确设置初始服务器版本它就可以工作(因此您要么没有运行2013,要么您在代码中没有显示其他问题).如果您正在寻找适用于Exchange 2007,2010和2013的内容,我建议您使用.
String MailboxToAccess = "user@domain.com";
ExchangeService service = new Microsoft.Exchange.WebServices.Data.ExchangeService(ExchangeVersion.Exchange2010_SP1);
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead,false);
service.Credentials = new NetworkCredential("user@domain.com", "password");
service.AutodiscoverUrl(MailboxToAccess, adAutoDiscoCallBack);
FolderId FolderToAccess = new FolderId(WellKnownFolderName.Inbox, MailboxToAccess);
ItemView ivItemView = new ItemView(10);
FindItemsResults<Item> FindItemResults = service.FindItems(FolderToAccess, sfSearchFilter, ivItemView);
PropertySet ItemPropertySet = new PropertySet(BasePropertySet.IdOnly);
ItemPropertySet.Add(ItemSchema.Body);
ItemPropertySet.RequestedBodyType = BodyType.Text;
if (FindItemResults.Items.Count > 0)
{
service.LoadPropertiesForItems(FindItemResults.Items, ItemPropertySet);
}
foreach (Item item in FindItemResults.Items)
{
Console.WriteLine(item.Body.Text);
}
internal static bool adAutoDiscoCallBack(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
这将只返回Text主体,并将适用于任何版本的EWS.
干杯
狭谷
内容总结
以上是互联网集市为您收集整理的c# – Exchange Server不支持所请求的版本全部内容,希望文章能够帮你解决c# – Exchange Server不支持所请求的版本所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。