Reputation: 37
For many months we used makeEwsRequestAsync
to update & send drafts right from the Add-In context. This approach is facing Outlook's cache mode limitations and forces us to retry EWS requests for unknown period of time before we can finish the process.
Considering real customers complains about processing time we have changed the flow and moved drafts processing to the backend.
Here's a schematic diagram of what're we trying to do - draft message processing flow
After shipping this change to production we faced 2 major issues that we're trying to investigate and resolve now. Here's some context:
There are number of drafts that never gets persisted on the backend: failed draft searches over retries. Increased number of NotFounds starting at 6 retry shows us that processing job was able to get an email for a while but it was sent by a customer manually.
We have tried using EWS on the backend a year ago to process emails on the backend, we had to revert as some of emails that we sent didn't match customer's expectations: random parts of email body were missing. Assuming that API synchronisation can take some time, we started inserting empty link to the email body using office-js
's body.prependAsync
. It looks like this: <a href="#sync-${syncId}">‌</a>
. By doing that we were able to verify that draft that we received through the API is synced to the point where user pressed command button. Unfortunately our 45 minutes for retries seems to be not enough to sync. failed sync_id check attempts
Upvotes: 1
Views: 820
Reputation:
How about skipping the drafts-collection step and getting the client to POST your back-end with a copy of the email themselves?
function sendit() {
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
var ewsId = Office.context.mailbox.item.itemId;
var token = result.value;
var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0);
var getMessageUrl = Office.context.mailbox.restUrl + "/v2.0/me/messages/" + restId;
var xhr = new XMLHttpRequest();
xhr.open("GET", getMessageUrl);
xhr.setRequestHeader("Authorization", "Bearer " + token);
xhr.onload = function(e) {
// Send this to your server:-
console.log(this.response); // <-- this is the complete email (excluding attachments though)
};
xhr.send();
});
}
Upvotes: 0