The Doctor
The Doctor

Reputation: 384

EWS: Mailbox address from a Calendar FolderId, is it possible?

I have stored Calendar FolderIds in order report on calendar events which a user has access to. I'm using Exchange Web Services via c# (using Microsoft.Exchange.WebServices)

These calendars can be associated with the authenticated user's mailbox, a shared mailbox, an impersonated|delegated mailbox, or a public mailbox. And now I'd like to go from the FolderId to the mailbox address.

Ideally there'd be a function to

string address = getMailboxAddress(new FolderId("AAJk...AA="));

Upvotes: 0

Views: 629

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

If you have the FolderId what you have is the EWS version of this https://msdn.microsoft.com/en-us/library/ee217297(v=exchg.80).aspx which means with the data you have doesn't contain the Email Address. You would be better at the time you store the CalendarId store the Email address its associated with.

You can try using ConvertId with a generic non resolvable email Address this should return the EmailAddress the folder belongs (won't work for Public Folder) to eg

     AlternateId aiAlternateid = new AlternateId(IdFormat.EwsId, SharedFoder.Id.UniqueId, "[email protected]");
    AlternateIdBase aiResponse = service.ConvertId(aiAlternateid, IdFormat.EwsId);
    Console.WriteLine(((AlternateId)aiResponse).Mailbox);

Cheers Glen

Upvotes: 1

Related Questions