Search code examples
office-jsoutlook-web-addinsoutlook-api

SetSelectedDataAsync Html Data Stripped Out When Using Outlook Desktop


I am trying to add hidden data to an Outlook email from an outlook web add-in so that I can use it later for linking the email back to other data.

I am using the setSelectedDataAsync method for this like so:

var content = 
              "<input type=\"hidden\" id=\"hidEmailTracking\" value='{\"syntheticConversationId\":\"" 
              + syntheticConversationId + "\"" +
              ",\"staffId\":" + staffId +
              ",\"countryCode\":\"" +  countryCode + "\"}'/>";

              item.body.setSelectedDataAsync(
                content,
                {coercionType: Office.CoercionType.Html}, function (result) {

However, when I send the email, Outlook Web keeps the hidden field that I have added but Outlook Desktop seems to strip it out. The email is set to HTML format.

Is there a way to mark the hidden html so that it doesn't get removed? Or alternatively is there another way of transporting hidden data in an outlook email that is compatible with both Outlook web and desktop?

thanks


Solution

  • We have an internet headers API that can be used to achieve your scenario. Documentation here: https://learn.microsoft.com/en-us/javascript/api/outlook/office.internetheaders?view=outlook-js-preview