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

问题描述

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



我的代码如下:

  ExchangeService EX =新ExchangeService(ExchangeVersion.Exchange2010_SP1); 
ex.AutodiscoverUrl([email protected]);

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

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


解决方案

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



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



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

  FindItemsResults<项目> findResults = ex.FindItems(
新FolderId(WellKnownFolderName.Inbox,新的邮箱([email protected])),
新ItemView控件(10));

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

  ExchangeService EX =新ExchangeService(ExchangeVersion:的FindItem 将在模拟用户的收件箱中工作。 Exchange2010_SP1); 
ex.AutodiscoverUrl([email protected]);
ex.ImpersonatedUserId =新ImpersonatedUserId([email protected]);
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("[email protected]");

    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("[email protected]")),
    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("[email protected]");
ex.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 02:15