简体   繁体   English

使用VSTO从Outlook 2013访问第二个交换收件箱

[英]Accessing 2nd exchange inbox from Outlook 2013 using VSTO

Getting default inbox works like the following: 获取默认收件箱的工作方式如下:

_outlookNameSpace = this.Application.GetNamespace("MAPI");
_inbox = _outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

Now on the same lines, how do get the inbox for the other exchange account say "abc@corp.com" ? 现在,在同一行上,如何使另一个交换帐户的收件箱说“ abc@corp.com”?

Thanks in advance. 提前致谢。

Assuming the second mailbox is already in the profile, you need to find the appropriate account in the Namespace.Stores collection and call Store.GetDefaultFolder. 假设第二个邮箱已经在配置文件中,则需要在Namespace.Stores集合中找到适当的帐户,然后调用Store.GetDefaultFolder。

Otherwise you can call Namespace.GetSharedDefaultFolder. 否则,您可以调用Namespace.GetSharedDefaultFolder。

I have a similar situation, where the 2nd account is identified by its .DisplayName property, which can be set in Account Setup. 我有一个类似的情况,第二个帐户由其.DisplayName属性标识,可以在“帐户设置”中设置该属性。 To find the Account, use: 要找到该帐户,请使用:

var account = Globals.Addin.Application.GetNamespace("MAPI")
                .Accounts.Cast<Account>()
                .FirstOrDefault(a => a.DisplayName == "TargetDisplayName");

Then use Account.DeliveryStore to get access to the store and find the folder. 然后使用Account.DeliveryStore获得对商店的访问权并找到文件夹。 .GetDefaultFolder gives you the folder: .GetDefaultFolder为您提供文件夹:

DraftsFolder = (Folder) account.DeliveryStore.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM