Skip to content

Commit

Permalink
[Outlook] (spam reporting) Add Office.onReady function (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
samantharamon authored May 1, 2024
1 parent 15b0646 commit d57b576
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Samples/outlook-spam-reporting/src/spamreporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
* Licensed under the MIT license.
*/

// Ensures the Office.js library is loaded.
Office.onReady(() => {
/**
* IMPORTANT: To ensure your add-in is supported in the classic Outlook client on Windows,
* remember to map the event handler name specified in the manifest to its JavaScript counterpart.
*/
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
Office.actions.associate("onSpamReport", onSpamReport); }
});

// Handles the SpamReporting event to process a reported message.
function onSpamReport(event) {
// Get the Base64-encoded EML format of a reported message.
Expand All @@ -23,7 +33,13 @@ function onSpamReport(event) {

// Run additional processing operations here.

/* Signals that the spam-reporting event has completed processing. It then moves the reported message to the Junk Email folder of the mailbox, then shows a post-processing dialog to the user. If an error occurs while the message is being processed, the `onErrorDeleteItem` property determines whether the message will be deleted. */
/**
* Signals that the spam-reporting event has completed processing.
* It then moves the reported message to the Junk Email folder of the mailbox,
* then shows a post-processing dialog to the user.
* If an error occurs while the message is being processed,
* the `onErrorDeleteItem` property determines whether the message will be deleted.
*/
const event = asyncResult.asyncContext;
event.completed({
onErrorDeleteItem: true,
Expand All @@ -36,7 +52,3 @@ function onSpamReport(event) {
}
);
}

// IMPORTANT: To ensure your add-in is supported in the Outlook client on Windows, remember to map the event handler name specified in the manifest to its JavaScript counterpart
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
Office.actions.associate("onSpamReport", onSpamReport); }

0 comments on commit d57b576

Please sign in to comment.