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" ?

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.

Otherwise you can call Namespace.GetSharedDefaultFolder.

其他提示

I have a similar situation, where the 2nd account is identified by its .DisplayName property, which can be set in Account Setup. 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. .GetDefaultFolder gives you the folder:

DraftsFolder = (Folder) account.DeliveryStore.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top