Makla
Makla

Reputation: 10459

Get Office 365 mail id int outlook or web for Graph API

Where can I found MessageId of a mail in Outlook? I need Id to pass it to Graph API, so this is not correct id.

It must be something like that:

AAE3NzVkZTAwLTNiM2MtNGUwNS1iYzNiLTZjNjM0YTc5985zJhZABGAAAAAABKvyNK5HPTSZZiT7al48txBwC12ftoWcMmSKHMBQzQpO
rDAAAAAAEMAAC12ftoWcMmSKHMBQzQKKJAADRLyVbAAA=

I need this for Graph -> Message API.

Upvotes: 0

Views: 465

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

Outlook uses the EntryID property value for identifying items in the store. To get EwsId you must convert it using the following code:

string ConvertHexEntryIdToEwsId(ExchangeService esb, string sID, string strSMTPAdd)
{
  AlternateId objAltID = new AlternateId();
  objAltID.Format = IdFormat.HexEntryId;
  objAltID.Mailbox = strSMTPAdd;
  objAltID.UniqueId = sID;

  AlternateIdBase objAltIDBase = esb.ConvertId(objAltID, IdFormat.EwsId);
  AlternateId objAltIDResp = (AlternateId)objAltIDBase;
  return objAltIDResp.UniqueId;
}

But I'd suggest using the approach described on the Convert Outlook REST API item id to MAPI EntryID page:

if you wanted to fetch a page of your messages and include the PR_ENTRYID, you could make a GET request to:

https://graph.microsoft.com/v1.0/me/messages?$expand=singleValueExtendedProperties($filter=id%20eq%20'Binary%200x0FFF')

Upvotes: 1

Related Questions