错误的邮箱项目使用Exchange Web服务被retreived管理API在C# [英] Wrong mailbox items being retreived using Exchange Web Services managed API in C#

查看:157
本文介绍了错误的邮箱项目使用Exchange Web服务被retreived管理API在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个特定的邮箱(在此我有权限)retreive的收件箱邮件,使用Exchange Web服务管理API。我测试首先通过AutodiscoverUrl用我自己的电子邮件地址代码,并能正常工作。然而,当我尝试使用其他电子邮件地址,EWS仍然检索我的收件箱中的物品。这是由于缓存的东西?



我的代码如下:

  ExchangeService EX =新ExchangeService(ExchangeVersion.Exchange2010_SP1); 
ex.AutodiscoverUrl(someothermailbox@company.com);

FindItemsResults<项目> findResults = ex.FindItems(WellKnownFolderName.Inbox,新ItemView控件(10));

的foreach(在findResults.Items项项)
Console.WriteLine(item.Subject);


解决方案

给电子邮件地址 AutodiscoverUrl 无关与邮箱要绑定到。



有(至少)两种方式来获得从其他用户的收件箱中的物品邮箱:委托访问和模拟。



如果您有其他用户邮箱的代理访问,您可以指定邮箱作为在调用 FindItems

  FindItemsResults<项目> findResults = ex.FindItems(
新FolderId(WellKnownFolderName.Inbox,新的邮箱(someothermailbox@company.com)),
新ItemView控件(10));

如果您拥有的权限来冒充其他用户,你也可以模拟连接到EWS,当其他用户及以下调用

  ExchangeService EX =新ExchangeService(ExchangeVersion:的FindItem 将在模拟用户的收件箱中工作。 Exchange2010_SP1); 
ex.AutodiscoverUrl(someothermailbox@company.com);
ex.ImpersonatedUserId =新ImpersonatedUserId(ConnectingIdType.SmtpAddresssomeothermailbox@company.com);
ItemsResults<项目> findResults = ex.FindItems(WellKnownFolderName.Inbox,新ItemView控件(10));



免责声明:我写上面的代码,而无需实际测试它真正的Exchange服务器上。


I'm trying to retreive Inbox items from a specific mailbox (in which i have permissions), using Exchange Web Services managed API. I've tested the code first using my own email address via AutodiscoverUrl, and it works fine. However when i tried using the other email address, EWS still retrieves my own inbox items. Is this due to a cache or something?

My code is as follows:

    ExchangeService ex = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    ex.AutodiscoverUrl("someothermailbox@company.com");

    FindItemsResults<Item> findResults = ex.FindItems(WellKnownFolderName.Inbox, new ItemView(10));

    foreach (Item item in findResults.Items)
         Console.WriteLine(item.Subject);

解决方案

The e-mail address given to AutodiscoverUrl has nothing to do with which mailbox you are binding to.

There are (at least) two ways to get the inbox items from another users mailbox: Delegate access and impersonation.

If you have delegate access to the other users mailbox, you can specify the mailbox as a parameter in the call to FindItems:

FindItemsResults<Item> findResults = ex.FindItems(
    new FolderId(WellKnownFolderName.Inbox, new Mailbox("someothermailbox@company.com")), 
    new ItemView(10));

If you have the permissions to impersonate the other user, you can impersonate the other user when connecting to the EWS and the following call to FindItem will work on the inbox of the impersonated user:

ExchangeService ex = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
ex.AutodiscoverUrl("someothermailbox@company.com");
ex.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "someothermailbox@company.com");
ItemsResults<Item> findResults = ex.FindItems(WellKnownFolderName.Inbox, new ItemView(10));

Disclaimer: I have written the above code without actually testing it on a real Exchange server.

这篇关于错误的邮箱项目使用Exchange Web服务被retreived管理API在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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