Outlook mail ID to communicate with Graph?

I have an Outlook Add-in mailitem that I need to find the ID, so I can us it to communicate with Microsoft Graph.

The mailitem EntryID is not the same as the Microsoft Graph message ID.

Only way I figure out to do it, is to get the PR_INTERNET_MESSAGE_ID like this:

Public Shared Function GetInternetMessageID(ByRef mail As MailItem) As String
    Try
        Dim s As String = mail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F").ToString.ToLower.Replace(vbCrLf, " ").Replace("  ", "").Replace("message-id:<", "message-id: <")
        Return "<" + s.GetInnerString("message-id: <", ">") + ">"
    Catch ex As System.Exception
        Return String.Empty
    End Try
End Function

And then get the message from Graph like this:

https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<HE1AR0301DD2555F3F27E45C4E1100@HE1PR1301MB2255.eurprd03.prod.outlook.com>'

But getting the "PropertyAccessor.GetProperty" from the code above is slow - takes like 3-4 seconds.

So now I have three IDs that is different:

  • MailItem EntryID
  • PR_INTERNET_MESSAGE_ID
  • Graph Message ID

Hmmmm.

Can I look up a Graph message using the mailitem EntryID? ... or can I find the Graph message ID in the Outlook mailitem?

How do you guys use Outlook Add-in mailitem and look up items in the Microsoft Graph for this mailitem?



Read more here: https://stackoverflow.com/questions/56017986/outlook-mail-id-to-communicate-with-graph

Content Attribution

This content was originally published by MojoDK at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: