共有メールボックス(自分の "[email protected]"でないメールボックス)からExchangeサーバーに接続してメールを読む方法を教えてください。ここで C#EWS Managed API:共有メールボックスにアクセスする方法(自分の受信トレイではない)
は、これまでの私のコードです://Create a service
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
//Autodiscover end point
service.AutodiscoverUrl("[email protected]");
FindFoldersResults folderSearchResults = service.FindFolders(WellKnownFolderName.Inbox, new FolderView(int.MaxValue));
Microsoft.Exchange.WebServices.Data.Folder exchangeMailbox = folderSearchResults.Folders.ToList().Find(
f => f.DisplayName.Equals("NameOfSharedMailboxIwant", StringComparison.CurrentCultureIgnoreCase));
//Set the number of items we can deal with at anyone time.
ItemView itemView = new ItemView(int.MaxValue);
foreach (Microsoft.Exchange.WebServices.Data.Folder folderFromSearchResults in folderSearchResults.Folders)
{
if (folderFromSearchResults.DisplayName.Equals("NameOfSharedMailboxIWant", StringComparison.OrdinalIgnoreCase))
{
Microsoft.Exchange.WebServices.Data.Folder boundFolder =
Microsoft.Exchange.WebServices.Data.Folder.Bind(service, folderFromSearchResults.Id);
SearchFilter unreadSearchFilter =
new SearchFilter.SearchFilterCollection(
LogicalOperator.And, new SearchFilter.IsEqualTo(
EmailMessageSchema.IsRead, false));
//Find the unread messages in the email folder.
FindItemsResults<Item> unreadMessages = boundFolder.FindItems(unreadSearchFilter, itemView);
foreach (EmailMessage message in unreadMessages)
{
message.Load();
Console.WriteLine(message.Subject);
}
}
私はこれを実行すると、私はその中に「SMTPアドレスは、それに関連付けられたメールボックスがありません」と述べているスローされた例外を取得:
Microsoft.Exchange.WebServices.Data.Folder exchangeMailbox = folderSearchResults.Folders.ToList().Find(
f => f.DisplayName.Equals("BA", StringComparison.CurrentCultureIgnoreCase));
を
私は何が欠けていますか?私はほとんどそこにいて、EWS Managed API 2.0のドキュメントに従って動作するはずですが、
見るために、常にあなたがの一部である共有メールボックスのすべてを列挙する方法はあり結果をパジェット? – Alexandru
私はここにフォローアップの質問を投稿しました:http://stackoverflow.com/questions/38881919/enumerating-shared-mailbox-names-you-are-able-to-access-using-ews-managed-api – Alexandru
これは答えは、よく知られたフォルダ名には適していません。 – Myzifer