質問

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