Skip to content

Commit d57b576

Browse files
[Outlook] (spam reporting) Add Office.onReady function (#768)
1 parent 15b0646 commit d57b576

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Samples/outlook-spam-reporting/src/spamreporting.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
* Licensed under the MIT license.
44
*/
55

6+
// Ensures the Office.js library is loaded.
7+
Office.onReady(() => {
8+
/**
9+
* IMPORTANT: To ensure your add-in is supported in the classic Outlook client on Windows,
10+
* remember to map the event handler name specified in the manifest to its JavaScript counterpart.
11+
*/
12+
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
13+
Office.actions.associate("onSpamReport", onSpamReport); }
14+
});
15+
616
// Handles the SpamReporting event to process a reported message.
717
function onSpamReport(event) {
818
// Get the Base64-encoded EML format of a reported message.
@@ -23,7 +33,13 @@ function onSpamReport(event) {
2333

2434
// Run additional processing operations here.
2535

26-
/* 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. */
36+
/**
37+
* Signals that the spam-reporting event has completed processing.
38+
* It then moves the reported message to the Junk Email folder of the mailbox,
39+
* then shows a post-processing dialog to the user.
40+
* If an error occurs while the message is being processed,
41+
* the `onErrorDeleteItem` property determines whether the message will be deleted.
42+
*/
2743
const event = asyncResult.asyncContext;
2844
event.completed({
2945
onErrorDeleteItem: true,
@@ -36,7 +52,3 @@ function onSpamReport(event) {
3652
}
3753
);
3854
}
39-
40-
// 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
41-
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
42-
Office.actions.associate("onSpamReport", onSpamReport); }

0 commit comments

Comments
 (0)