0

In a VSTO add-in, I am trying to retrieve if the type of the mailbox is shared, user or resource. I read some interesting posts related to the question and try to look at the OlExchangeStoreType or GetConversation or MailboxType but did not succeed. I have seen the solution (3) from @DmitryStreblechenko but I would prefer to not use EWS if possible. It seems that the value that I am looking for is the msExchRecipientTypeDetails. Any help would be highly appreciated.

Relevant articles

  1. EWS Get mailbox type (user/resource/shared)

  2. MailItem.GetConversation() on shared mailbox

  3. In Outlook Addin, how do I determine if an email's Sender is a shared mailbox email address?

  4. https://www.codeproject.com/Questions/1088741/How-to-list-subfolders-in-inbox-folder-in-shared-e

  5. https://learn.microsoft.com/en-us/answers/questions/612248/in-outlook-addin-how-do-i-determine-that-an-email.html

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Salim
  • 495
  • 3
  • 20

2 Answers2

0

First of all, VSTO doesn't provide anything for that.

Second, the Outlook object model doesn't differentiate shared/local stores. So, you will not find any property or method for that in the OOM. The best what you could do is to use the Store.ExchangeStoreType property which returns a constant in the OlExchangeStoreType enumeration that indicates the type of an Exchange store.

It is up to you which way/workaround is to use form the list shared above.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks Eugene. I don't see how the OlExchangeStoreType can help. Shared and user mailboxes return olPrimaryExchangeMailbox. Did you think of something in particular? – Salim Jun 19 '22 at 07:29
  • That is definitely not a solution. As a I wrote, the OOM doesn't provide anything for that. – Eugene Astafiev Jun 19 '22 at 07:33
0

You don't need to use EWS - try to read Namespace.AutoDiscoverXml property to check if the shared mailbox and its type are there - you can see it in OutlookSpy (I am its author): click Namespace button, select AutoDiscoverXml property.

Look for the AlternativeMailbox\Type nodes - you can have "Archive", "Delegate", "TeamMailbox".

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Hello Dimitry, nice to hear from you as always! Yes, I noticed the solution provided under link 3 but unfortunately I am not dealing with a mail but with an appointment item. I am not sure if it is related but the autodiscover property of the appointment does not include the alternative AlternativeMailbox\Type. I have tried with app.Session.AutoDiscoverXml or app.Parent.Session.AutoDiscoverXml. – Salim Jun 20 '22 at 05:30
  • Yes Autodiscover is specific to a particular Exchange account, I am not sure how it relates to a particular appointment. Do you mean you are trying to find out what the parent mailbox/store is? – Dmitry Streblechenko Jun 20 '22 at 15:14
  • Thanks for your answer. In the case of my add-in, I only have an appointment item which is being open by the user. I am trying to understand if the appointment (app) is from the user calendar or from shared calendar. I have try the autodiscover on "app.GetOrganizer().GetExchangeUser().Session.Accounts", " app.Session.Accounts" or "app.Parent.Session.Accounts" but none of those get me an AutoDiscoverXML with the AlternativeMailbox node. The mailbox is a M365 mailbox. – Salim Jun 25 '22 at 04:32
  • What do you see for that mailbox in Namespace.AutoDiscoverXml? – Dmitry Streblechenko Jun 26 '22 at 00:57