Graph API detect O365 mailbox type

Something I came across the other day and file away before I close the tab.

A while ago I had blogged on how to detect if a user has an O365 mailbox or not (fun story, I forgot I had blogged about that and discovered it again when Googling 😀).

Anyways, I can across something else last week. The userPurpose property. This is a part of the mailboxSettings property I was querying in that blog post, and one can use that to determine the type of the mailbox.

Only catch is to retrieve this piece of info you also need MailboxSettings.Read or MailboxSettings.Write permissions too. In fact, lack of this is what results in getting an “Access is denied. Check credentials and try again.” error message otherwise, which is what I was using to detect that there is in fact an O365 mailbox associated with the account.