Office.SpamReportingEventCompletedOptions interface

指定 集成垃圾邮件报告加载项 在完成处理 SpamReporting 事件后的行为。

注解

[ API set: Mailbox 1.14 ]

最低权限级别读取项

适用的 Outlook 模式:邮件读取

示例

// The following example handles a SpamReporting event to process a reported spam or phishing message.
function onSpamReport(event) {
    // Gets the Base64-encoded EML format of a reported message.
    Office.context.mailbox.item.getAsFileAsync({ asyncContext: event }, (asyncResult) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.log(`Error encountered during message processing: ${asyncResult.error.message}`);
            return;
        }

        // Run additional processing operations here.

        /**
         * Signals that the spam-reporting event has completed processing.
         * It then moves the reported message to a custom mailbox folder named "Reported Messages"
         * and 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({
            moveItemTo: Office.MailboxEnums.MoveSpamItemTo.CustomFolder,
            folderName: "Reported Messages",
            onErrorDeleteItem: true,
            showPostProcessingDialog: {
                title: "Contoso Spam Reporting",
                description: "Thank you for reporting this message.",
            },
        });
    });
}

属性

commandId

使用 completed 方法 指示报告的消息已完成处理时,此属性指定在处理消息后打开的任务窗格的 ID。

contextData

使用 completed 方法 指示报告的消息已完成处理时,此属性指定在处理消息后传递到外接程序任务窗格的任何 JSON 数据。

folderName

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定邮件将移动到的 Outlook 邮箱文件夹。

moveItemTo

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定是否将邮件移动到邮箱中的其他文件夹。

onErrorDeleteItem

如果设置为 true,则在处理消息时发生错误,则删除报告的消息。 如果此属性设置为 false 或未在 completed 方法中指定,则报告的邮件将保留在其当前邮箱文件夹中。

postProcessingAction

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定是否将邮件移动到邮箱中的其他文件夹。 以下后处理作可用。

  • delete - 将报告的邮件移动到邮箱的 “已删除邮件” 文件夹。

  • moveToCustomFolder - 将报告的邮件移动到指定的文件夹。 必须在 属性中 folderName 指定文件夹的名称。

  • moveToSpamFolder- 将报告的邮件移动到邮箱的“垃圾邮件Email”文件夹。

  • noMove - 将报告的邮件保留在其当前文件夹中。

showPostProcessingDialog

使用 completed 方法 指示报告的消息已完成处理时,此属性指示是否向用户显示后期处理对话框。 分配给此属性的 JSON 对象必须包含标题和说明。 如果未指定此属性,则处理用户报告的消息后,不会向用户显示对话框。

属性详细信息

commandId

使用 completed 方法 指示报告的消息已完成处理时,此属性指定在处理消息后打开的任务窗格的 ID。

commandId?: string;

属性值

string

注解

[ API set: Mailbox 1.15 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要说明

  • 若要了解如何在垃圾邮件报告加载项中实现 commandId 属性,请参阅 报告邮件后打开任务窗格。

  • 该值 commandId 必须与外接程序清单中指定的任务窗格 ID 匹配。 在 Microsoft 365 的统一清单中,ID 在表示任务窗格的 “extensions.ribbons.tabs.groups.controls”对象的“id” 属性中指定。 在仅外接程序清单中,ID 在代表任务窗格的 Control 元素的 属性中id指定。

  • 如果在调用中event.completed配置 commandId 选项,即使调用中指定了选项,showPostProcessingDialog也不会向用户显示后处理对话框。

  • 若要确保在报告邮件后打开垃圾邮件报告加载项的任务窗格,必须将调用 Office.MailboxEnums.MoveSpamItemTo.NoMove的选项event.completed设置为 moveItemTo

  • 如果实现在处理报告的消息后打开的任务窗格,则 event.completed 当调用发生时,打开或固定的任何任务窗格将关闭。

示例

function onSpamReport(event) {
    // Run operations to process the reported message.

    /**
     * Signals that the spam-reporting event has completed processing.
     * A task pane is opened instead of showing a post-processing dialog.
     * Context data is then passed to the task pane for processing.
     * To ensure that the task pane opens and receives the context data,
     * the reported message mustn't be moved from the folder in which it resides.
     */
    event.completed({
        commandId: "msgReadOpenPaneButton",
        contextData: JSON.stringify({ a: "aValue", b: "bValue" }),
        moveItemTo: Office.MailboxEnums.MoveSpamItemTo.NoMove
    });
}

contextData

使用 completed 方法 指示报告的消息已完成处理时,此属性指定在处理消息后传递到外接程序任务窗格的任何 JSON 数据。

contextData?: any;

属性值

any

注解

[ API set: Mailbox 1.15 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要说明

  • 若要了解如何在垃圾邮件报告加载项中实现 contextData 属性,请参阅 报告邮件后打开任务窗格。

  • 如果在调用中event.completed指定选项contextData,还必须为commandId选项分配任务窗格 ID。 否则,将忽略分配给 contextData 的 JSON 数据。

  • 如果在调用中event.completed配置 commandIdcontextData 选项,即使调用中指定了选项,showPostProcessingDialog也不会向用户显示后处理对话框。

  • 若要确保垃圾邮件报告加载项的任务窗格在报告邮件后打开并接收上下文数据,必须将调用Office.MailboxEnums.MoveSpamItemTo.NoMove的选项event.completed设置为 moveItemTo

  • 如果实现在处理报告的消息后打开的任务窗格,则 event.completed 当调用发生时,打开或固定的任何任务窗格将关闭。

  • 若要防止垃圾邮件报告加载项的任务窗格在已打开时重新启动,请为 Office.EventType.InitializationContextChanged 事件实现处理程序。 然后,可以将 事件参数 传递给 contextData 属性。

  • 若要检索 属性的值 contextData ,必须在任务窗格的 JavaScript 实现中调用 Office.context.mailbox.item.getInitializationContextAsync 。 如果使用 创建 JSON 字符串 JSON.stringify() 并将其分配给 contextData 属性,则必须在检索该字符串后使用 JSON.parse() 分析该字符串。

示例

function onSpamReport(event) {
    // Run operations to process the reported message.

    /**
     * Signals that the spam-reporting event has completed processing.
     * A task pane is opened instead of showing a post-processing dialog.
     * Context data is then passed to the task pane for processing.
     * To ensure that the task pane opens and receives the context data,
     * the reported message mustn't be moved from the folder in which it resides.
     */
    event.completed({
        commandId: "msgReadOpenPaneButton",
        contextData: JSON.stringify({ a: "aValue", b: "bValue" }),
        moveItemTo: Office.MailboxEnums.MoveSpamItemTo.NoMove
    });
}

folderName

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定邮件将移动到的 Outlook 邮箱文件夹。

folderName?: string;

属性值

string

注解

[ API set: Mailbox 1.14 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要说明

  • 如果指定的文件夹尚不存在,则会在邮件移动之前创建该文件夹。

  • 如果属性 postProcessingAction 设置为 moveToCustomFolder,则必须指定 属性 folderName 。 否则,报告的邮件将移动到邮箱的“垃圾邮件Email”文件夹中。 如果 postProcessingAction 设置为以外的 moveToCustomFolder其他作,则忽略 属性 folderName

moveItemTo

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定是否将邮件移动到邮箱中的其他文件夹。

moveItemTo?: MailboxEnums.MoveSpamItemTo;

属性值

注解

[ API set: Mailbox 1.14 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要说明

  • 你只能在 Outlook 网页版 中的垃圾邮件报告加载项中使用此属性,在 Windows (从版本 2308、内部版本 16724.10000) ) 和 Mac 开始的新的和经典 (。 如果你使用的是支持集成垃圾邮件报告功能的早期经典 Windows 版 Outlook,请改用 postProcessingAction 属性。

  • 如果 属性设置为 Office.MailboxEnums.MoveSpamItemTo.CustomFolder,则必须在调用的 属性event.completedfolderName指定要将邮件移动到的文件夹的名称。 否则, moveItemTo 属性将默认为 Office.MailboxEnums.MoveSpamItemTo.JunkFolder ,并将报告的邮件移动到 “垃圾邮件Email” 文件夹。

  • 如果在用户从预处理对话框中选择“报表”选项后,在调用中event.completed配置 commandIdcontextData 选项以打开任务窗格,则必须将 moveItemTo 选项设置为 Office.MailboxEnums.MoveSpamItemTo.NoMove。 否则,任务窗格将无法打开。

onErrorDeleteItem

如果设置为 true,则在处理消息时发生错误,则删除报告的消息。 如果此属性设置为 false 或未在 completed 方法中指定,则报告的邮件将保留在其当前邮箱文件夹中。

onErrorDeleteItem?: boolean;

属性值

boolean

注解

[ API set: Mailbox 1.14 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

postProcessingAction

使用 completed 方法 指示报告的邮件已完成处理时,此属性指定是否将邮件移动到邮箱中的其他文件夹。 以下后处理作可用。

  • delete - 将报告的邮件移动到邮箱的 “已删除邮件” 文件夹。

  • moveToCustomFolder - 将报告的邮件移动到指定的文件夹。 必须在 属性中 folderName 指定文件夹的名称。

  • moveToSpamFolder- 将报告的邮件移动到邮箱的“垃圾邮件Email”文件夹。

  • noMove - 将报告的邮件保留在其当前文件夹中。

postProcessingAction?: string;

属性值

string

注解

[ API set: Mailbox 1.14 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要说明

  • 在 Outlook on Windows 中,只能在支持集成垃圾邮件报告功能的早期版本中使用此属性。 如果使用版本 2308 (内部版本 16724.10000) 或更高版本,请改用 moveItemTo 属性。

  • Outlook 网页版、Mac 或 Windows 版 Outlook 中不支持此属性。 moveItemTo请改用 属性。

  • 如果 属性设置为 moveToCustomFolder,则必须在调用的 属性event.completedfolderName指定要将邮件移动到的文件夹的名称。 否则, postProcessingAction 属性将默认为 moveToSpamFolder ,并将报告的邮件移动到 “垃圾邮件Email” 文件夹。

示例

// The following example handles a SpamReporting event to process a reported spam or phishing message.
function onSpamReport(event) {
    // Gets the Base64-encoded EML format of a reported message.
    Office.context.mailbox.item.getAsFileAsync({ asyncContext: event }, (asyncResult) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.log(`Error encountered during message processing: ${asyncResult.error.message}`);
            return;
        }

        // 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 and shows a
         * post-processing dialog to the user.
         */
        const event = asyncResult.asyncContext;
        event.completed({
            postProcessingAction: "moveToSpamFolder",
            showPostProcessingDialog: {
                title: "Contoso Spam Reporting",
                description: "Thank you for reporting this message.",
            },
        });
    });
}

showPostProcessingDialog

使用 completed 方法 指示报告的消息已完成处理时,此属性指示是否向用户显示后期处理对话框。 分配给此属性的 JSON 对象必须包含标题和说明。 如果未指定此属性,则处理用户报告的消息后,不会向用户显示对话框。

showPostProcessingDialog?: object;

属性值

object

注解

[ API set: Mailbox 1.14 ]

最低权限级别 (Outlook) read item

适用的 Outlook 模式:邮件读取

重要提示:如果在用户从预处理对话框中选择“报表”选项后,在调用中event.completed配置 commandIdcontextData 选项以打开任务窗格,则不会向用户显示后处理对话框。 即使调用中event.completed指定了 ,showPostProcessingDialog此行为也会适用。