0

I am developing an Outlook add-in that sets the mail body to some specific content, then sends the mail. However, the Office.js APIs do not offer the send mail functionality; hence the mail has to be sent either by making an EWS request or by using Graph.

If Office.Body.setAsync is called, is the mail guaranteed to be synced with the server? If not, is there any way to ensure the same?

The Office.MessageCompose.saveAsync docs mention the following:

If your add-in calls saveAsync on an item in compose mode in order to get an item ID to use with EWS or the REST API, be aware that when Outlook is in cached mode, it may take some time before the item is actually synced to the server. Until the item is synced, using the item ID will return an error.

Is the above applicable to Office.Body.setAsync as well? If yes, how do you "force" a sync. And if you can't do that either, how do you know the mail has synced? When a sendMail request is fired via Graph, how does one assert that the mail content has been set successfully?

  • 1
    What's mentioned above in the doc is applicable to Office.Body.setAsync. There is no way to force the sync, but before sending the mail via Graph you can add logic to get the body via Graph to double check if the content is set and only send when the desired content does get synced. On a side note, do you mind sharing the use case for this? Is it the preferred behavior for the add-in to add content and automatically send the email for the user? – Outlook Add-ins Team - MSFT May 19 '21 at 00:34
  • @OutlookAdd-insTeam-MSFT The add-in in question has a button. On the click of that button, it's going to process the mail body on the server side, make changes to it, set the body accordingly and send the mail. – Pratik_Seclore May 21 '21 at 10:03
  • @OutlookAdd-insTeam-MSFT Also, the docs mention that Body.getAsync and Body.setAsync methods are not idempotent. So how do I double check if the content is set even if I get the body via Graph? Just to clarify my previous comment, the body is being set on client-side after getting processed on the server-side. – Pratik_Seclore May 21 '21 at 11:06
  • In order to check if the content is set, you can set the body and then also set a custom property from the client side. After that, use Graph to see if the custom property is there. If the custom property is there then the body content is also synced. As for how to get custom properties from Graph, you can refer to the answers on this page: https://stackoverflow.com/a/43140462/7823505 – Outlook Add-ins Team - MSFT May 22 '21 at 00:48

0 Answers0