Reputation: 89
I am currently working on a web add-in that processes, modify and then sends the email.
I'm attached to the ItemSend event: <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateBody" />
. This validate the body and then sends it.
The problem I have is that processing the email might take up to 40 seconds and I don't want the user to be blocked for that amount of time.
I was wondering is there a way to minimize the compose window and still run the processing function and the close that minimized window once its done?
I know that the add-in only works on the current item so when I send the email I can still access the other pages but once the email is trying to send itself and close the compose window nothing happens.
This is the function that sends the email:
async function sendInBackGround(htmlArr, message = "") {
const subject = await getEmailSubject();
const messageDiv = "<div>" + message + "</div>";
for (const htmlArrObject of htmlArr) {
debugger;
var request = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
' <soap:Header><t:RequestServerVersion Version="Exchange2010" /></soap:Header>' +
' <soap:Body>' +
' <m:CreateItem MessageDisposition="SendOnly">' +
' <m:Items>' +
' <t:Message>' +
' <t:Subject>' + subject.value + '</t:Subject>' +
' <t:Body BodyType="HTML"><![CDATA[' + htmlArrObject.html + messageDiv + ']]></t:Body>' +
' <t:ToRecipients>' +
' <t:Mailbox><t:EmailAddress>' + htmlArrObject.recipient + '</t:EmailAddress></t:Mailbox>' +
' </t:ToRecipients>' +
' </t:Message>' +
' </m:Items>' +
' </m:CreateItem>' +
' </soap:Body>' +
'</soap:Envelope>';
Office.context.mailbox.makeEwsRequestAsync(request, (asyncResult) => {
console.log(request);
if (asyncResult.status === "failed") {
console.log("Action failed with error: " + asyncResult.error.message);
}
else {
console.log("Message sent!");
mailboxItem.close();
}
});
}
}
When I send the item and wait on the compose window for the process to be done, the asyncResult has a status and a value that are defined. But when I change windows while the process is running, for example I go on an other compose window and start writing another email, the asyncResult object has a status of succeeded but the value returned is undefined.
Can someone help?
Upvotes: 0
Views: 132
Reputation: 49395
I was wondering is there a way to minimize the compose window and still run the processing function and the close that minimized window once its done?
No, there is no way with web-based add-ins. You can post your feature request/suggestion to the Tech Community Page. Don't forget to choose the appropriate label(s). Feature requests on Tech Community
are considered when the team go through the planning process.
As a side note, you can implement the required functionality with COM based add-ins nowadays. For example, you may consider developing a VSTO add-in instead, see Walkthrough: Create your first VSTO Add-in for Outlook for more information.
Upvotes: 0