none
contains method not working with HTML in GET request RRS feed

  • Question

  • Hello!

    I am using office 365 for my result distribution purpose. I wanna track, whether the email is delivered successfully or not. For that, I am creating a record for each email in database. And I'm including this record ID in email as a hidden field.

    Here are the steps I'm following to update my record status in database based on email is delivered or not.

    1. I'm iterating through all records whose status is 'pending'
    2. And I'm firing a GET request for each record (https://outlook.office.com/api/v2.0/me/mailfolders/sentitems/messages?$filter=contains(Body/Content,\'<RECORD_ID>\')). Here RECORD_ID is a hidden field in email

    But in response, I'm getting 0 results. If I'm firing the same request with some static text(other than HTML text), it is returning the proper results.

    Can anyone help me with this scenario? Thanks in advance.

    Thursday, July 28, 2016 10:08 AM

Answers

  • Hi Pavan,

    In this scenario, you can store the custom data to the Data Extensions. Here is example for your reference:
    Create data extensions:

    POST https://outlook.office.com/api/v2.0/me/messages/{messageId}/extensions 
    
    authorization: bearer {token}
    content-type: application/json
    
    {
       @odata.type: "Microsoft.OutlookServices.OpenTypeExtension",  
       "ExtensionName": "Record",
       "RecordId": "12345"
     
    }

    Filter the messages using this data extensions:

    GET https://outlook.office.com/api/v2.0/me/messages?$filter=Extensions/any(f:f/Id+eq+'Record')&$expand=Extensions($filter=Id+eq+'Record') HTTP/1.1
    authorization: bearer {token}
    

    More detail about data extensions please refer to here.

    Regards & Jupiter


    Friday, July 29, 2016 5:30 AM
  • >>How to filter by other properties other than extension name(like Company Name, TopModels, TopSalespersons, etc..) in the given example

    At present, we are only able to filter the data using the extension id. In this scenario, you can filter the record returned by the request as a workaround.

    >>Does this extension passes on the inbox email when we enable delivery receipt? I want to know if the email is delivered successfully or not. But if I'm searching with the extension ID, I'm getting only one item in result(sent item). But I got the delivery receipt for this sent item. How can I see this result also in filter?

    The extension would deliver with the message to the receipts. However the extension wouldn't pass to the response messages of Request a Deliver Receipt feature. In this scenario, you could get the ConversationId

    of the response messages and get the sent message based on the ConversationId. At last you can retrieve the data extension you crated in the original messages.

    And if you have any feedback about the Office 365 REST API, you can submit them from here.

    Hope it is helpful.

    Regards & Jupiter



    Tuesday, August 2, 2016 6:16 AM

All replies

  • Hello Pavan,

    Basically this means the filter works only on the text of HTML, all tags are not the part of this search. As the value of the hidden input is the part of the tag it will not be part of the search.

    You probably need to find another way to store your information alone with the message. The right way would be to store your information in a transport header property. To continue work with body of the message you may cheat and add your "RECORD_ID" info into <font> HTML tag with color of the body and it will be hidden ;) User won't see white on white ...

    <font color="color_of_message_body">RECORD_ID</font>


    Slava Ivanov

    Thursday, July 28, 2016 6:16 PM
  • Thank you Slava Ivanov for understanding my requirement, and suggesting accordingly!

    As you suggested, I'm setting record ID in header as follows:

     HttpRequest req = new HttpRequest(); 

    req.setHeader('authorization', 'Bearer ' + accesssToken);

    req.setHeader('RECORD_ID', '1234');



    Could you please let me know how to search for that header(RECORD_ID) in office365 GET request?

    Friday, July 29, 2016 4:56 AM
  • Hi Pavan,

    In this scenario, you can store the custom data to the Data Extensions. Here is example for your reference:
    Create data extensions:

    POST https://outlook.office.com/api/v2.0/me/messages/{messageId}/extensions 
    
    authorization: bearer {token}
    content-type: application/json
    
    {
       @odata.type: "Microsoft.OutlookServices.OpenTypeExtension",  
       "ExtensionName": "Record",
       "RecordId": "12345"
     
    }

    Filter the messages using this data extensions:

    GET https://outlook.office.com/api/v2.0/me/messages?$filter=Extensions/any(f:f/Id+eq+'Record')&$expand=Extensions($filter=Id+eq+'Record') HTTP/1.1
    authorization: bearer {token}
    

    More detail about data extensions please refer to here.

    Regards & Jupiter


    Friday, July 29, 2016 5:30 AM
  • Cool. I could able to filter it out by extension name.

    Here are few questions:

    1. May I know how to use CONTAINS in filter with extensions.
    2. How to filter by other properties other than extension name(like Company Name, TopModels, TopSalespersons, etc..) in the given example
    3. Does this extension passes on the inbox email when we enable delivery receipt? I want to know if the email is delivered successfully or not. But if I'm searching with the extension ID, I'm getting only one item in result(sent item). But I got the delivery receipt for this sent item. How can I see this result also in filter?

    Thank you for your patience.



    • Edited by Pavan Elthepu Friday, July 29, 2016 9:07 AM
    • Proposed as answer by Jupiter Xue Thursday, August 4, 2016 3:00 AM
    • Unproposed as answer by Jupiter Xue Thursday, August 4, 2016 3:00 AM
    Friday, July 29, 2016 8:55 AM
  • Any updates on this?
    Monday, August 1, 2016 5:44 AM
  • >>How to filter by other properties other than extension name(like Company Name, TopModels, TopSalespersons, etc..) in the given example

    At present, we are only able to filter the data using the extension id. In this scenario, you can filter the record returned by the request as a workaround.

    >>Does this extension passes on the inbox email when we enable delivery receipt? I want to know if the email is delivered successfully or not. But if I'm searching with the extension ID, I'm getting only one item in result(sent item). But I got the delivery receipt for this sent item. How can I see this result also in filter?

    The extension would deliver with the message to the receipts. However the extension wouldn't pass to the response messages of Request a Deliver Receipt feature. In this scenario, you could get the ConversationId

    of the response messages and get the sent message based on the ConversationId. At last you can retrieve the data extension you crated in the original messages.

    And if you have any feedback about the Office 365 REST API, you can submit them from here.

    Hope it is helpful.

    Regards & Jupiter



    Tuesday, August 2, 2016 6:16 AM
  • Thank you!
    Wednesday, August 3, 2016 12:07 PM