Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top