Outlook REST API to extract URLs in the message body

271 Views Asked by At

Is there an Outlook REST API that gives me all the urls extracted from the body of the message? Some thing like what EWS's EntityExtractionResult does?

1

There are 1 best solutions below

0
On

No there isn't. However, you can retrieve extended properties, so you should be able to request the PidNameExtractedUrls property.

If you dig through those open specs, you should find these details on PidNameExtractedUrls:

Property set: PSETID_XmlExtractedEntities {23239608-685D-4732-9C55-4C95CB4E8E33}
Property name: XmlExtractedUrls

So that would mean I could make the following request (assuming you're using the Outlook endpoint, not Graph):

GET https://outlook.office.com/api/v2.0/me/messages?$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String {23239608-685D-4732-9C55-4C95CB4E8E33} Name XmlExtractedUrls')

For Graph, you would replace PropertyId with id.

That will include something like this in the message entities that have this property set:

"SingleValueExtendedProperties": [
    {
        "PropertyId": "String {23239608-685d-4732-9c55-4c95cb4e8e33} Name XmlExtractedUrls",
        "Value": "<?xml version=\"1.0\" encoding=\"utf-16\"?><UrlSet><Version>15.0.0.0</Version><Urls><Url StartIndex=\"0\"><UrlString>https://www.google.com</UrlString></Url><Url StartIndex=\"23\"><UrlString>https://developer.microsoft.com/outlook</UrlString></Url></Urls></UrlSet>"
    }
]