Office.SpamReportingEventCompletedOptions interface
指定 集成垃圾邮件报告加载项 在处理完 SpamReporting 事件后的行为。
注解
最低权限级别: 读取项目
适用的 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.",
},
});
});
}
属性
| command |
使用 completed 方法 表示报告的邮件已处理完时,此属性指定处理消息后打开的任务窗格的 ID。 |
| context |
使用 completed 方法 表示报告的消息已处理完时,此属性指定在处理消息后传递到加载项任务窗格的任何 JSON 数据。 |
| folder |
使用 completed 方法 表示报告的邮件已处理完毕时,此属性指定邮件将移动到的 Outlook 邮箱文件夹。 |
| move |
使用 completed 方法 表示报告的邮件已处理完时,此属性指定是否将邮件移至邮箱中的其他文件夹。 |
| on |
如果设置为 ,则 |
| post |
使用 completed 方法 表示报告的邮件已处理完时,此属性指定是否将邮件移至邮箱中的其他文件夹。 以下后期处理操作可用。
|
| show |
当使用 completed 方法 表示报告的邮件已完成处理时,此属性指示是否向用户显示后处理对话框。 分配给此属性的 JSON 对象必须包含标题和说明。 如果未指定此属性,则在处理用户报告的邮件后,不会向用户显示对话框。 |
属性详细信息
commandId
使用 completed 方法 表示报告的邮件已处理完时,此属性指定处理消息后打开的任务窗格的 ID。
commandId?: string;
属性值
string
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要说明:
若要了解如何在垃圾邮件报告加载项中实现该
commandId属性,请参阅 “报告消息后打开任务窗格”。该
commandId值必须与加载项清单中指定的任务窗格 ID 匹配。 在 Microsoft 365 统一清单中,ID 在表示任务窗格的 “extensions.ribbons.tabs.groups.controls” 对象的“id”属性中指定。 在仅加载项清单中,在表示任务窗格的控件元素的属性中id指定 ID。如果在通话中
event.completed配置该commandId选项,则即使在通话中指定了该showPostProcessingDialog选项,也不会向用户显示后处理对话框。若要确保在报告邮件后打开垃圾邮件报告加载项的任务窗格,必须将
moveItemTo调用Office.MailboxEnums.MoveSpamItemTo.NoMove的event.completed选项设置为 。如果实现在处理报告的邮件后打开的任务窗格,则当调用发生时
event.completed,任何打开或固定的任务窗格都将关闭。从版本 16.103 开始,该
commandId选项可在 Mac 上的 Outlook 中预览 (内部版本 25101816) 。 若要测试此选项,请加入 Microsoft 365 预览体验计划 并选择 “Beta 版频道 ”选项以访问 Office Beta 版本。
示例
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
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要说明:
若要了解如何在垃圾邮件报告加载项中实现该
contextData属性,请参阅 “报告消息后打开任务窗格”。如果在通话中
event.completed指定该contextData选项,还必须为该commandId选项分配任务窗格 ID。 否则,将忽略分配给contextData的 JSON 数据。如果在调用中
event.completed配置 andcontextDatacommandId选项,则即使在调用中指定了该showPostProcessingDialog选项,也不会向用户显示后处理对话框。要确保在报告邮件后打开垃圾邮件报告加载项的任务窗格并接收上下文数据,必须将
moveItemTo调用Office.MailboxEnums.MoveSpamItemTo.NoMove的event.completed选项设置为 。如果实现在处理报告的邮件后打开的任务窗格,则当调用发生时
event.completed,任何打开或固定的任务窗格都将关闭。若要防止重新启动垃圾邮件报告加载项的任务窗格(如果它已打开),请实现事件的
Office.EventType.InitializationContextChanged处理程序。 然后,可以将 事件参数 传递给contextData属性。若要检索属性的
contextData值,必须调用Office.context.mailbox.item.getInitializationContextAsync任务窗格的 JavaScript 实现。 如果使用JSON.stringify()JSON 字符串创建 JSON 字符串并将其分配给contextData属性,则必须在检索字符串后使用它来JSON.parse()解析字符串。从版本 16.103 开始,该
contextData选项可在 Mac 上的 Outlook 中预览 (内部版本 25101816) 。 若要测试此选项,请加入 Microsoft 365 预览体验计划 并选择 “Beta 版频道 ”选项以访问 Office Beta 版本。
示例
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
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要说明:
如果指定的文件夹尚不存在,将在移动邮件之前创建该文件夹。
如果该
postProcessingAction属性设置为moveToCustomFolder,则必须指定该folderName属性。 否则,报告的邮件将移动到邮箱的 Junk Email 文件夹。 如果设置为除 之外的另一个操作moveToCustomFolder,则postProcessingAction忽略该folderName属性。
moveItemTo
使用 completed 方法 表示报告的邮件已处理完时,此属性指定是否将邮件移至邮箱中的其他文件夹。
moveItemTo?: MailboxEnums.MoveSpamItemTo;
属性值
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要说明:
只能在 Outlook 网页版、Windows (从版本 2308 开始的新版和经典 ((内部版本 16724.10000) ) )和 Mac 上的垃圾邮件报告加载项中使用此属性。 如果使用的是支持集成垃圾邮件报告功能的 Windows 上的经典 Outlook 的较早版本,请改用该
postProcessingAction属性。如果该属性设置为
Office.MailboxEnums.MoveSpamItemTo.CustomFolder,则必须在调用的event.completed属性中folderName指定邮件要移动到的文件夹的名称。 否则,该moveItemTo属性将默认为Office.MailboxEnums.MoveSpamItemTo.JunkFolder,并将报告的邮件移动到 Junk Email 文件夹。如果在用户从预处理对话框中选择“报表”选项后在调用中
event.completed配置commandIdandcontextData选项以打开任务窗格,则必须将该moveItemTo选项Office.MailboxEnums.MoveSpamItemTo.NoMove设置为 。 否则,任务窗格将无法打开。
onErrorDeleteItem
如果设置为 ,则 true在处理消息时发生错误时删除报告的消息。 如果在 completed 方法中设置为false或未指定此属性,则报告的邮件仍保留在其当前邮箱文件夹中。
onErrorDeleteItem?: boolean;
属性值
boolean
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
postProcessingAction
使用 completed 方法 表示报告的邮件已处理完时,此属性指定是否将邮件移至邮箱中的其他文件夹。 以下后期处理操作可用。
delete- 将报告的邮件移动到邮箱的 “已删除邮件 ”文件夹。moveToCustomFolder- 将举报的邮件移动到指定的文件夹。 您必须在属性中folderName指定文件夹的名称。moveToSpamFolder- 将报告的邮件移动到邮箱的 Junk Email 文件夹。noMove- 将报告的邮件保留在其当前文件夹中。
postProcessingAction?: string;
属性值
string
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要说明:
在 Windows 上的 Outlook 中,只能在支持集成垃圾邮件报告功能的早期版本中使用此属性。 如果你使用的是版本 2308 (内部版本 16724.10000) 或更高版本,请改用该
moveItemTo属性。Outlook 网页版、Mac 或 Windows 上的新 Outlook 不支持此属性。 请改用该
moveItemTo属性。如果该属性设置为
moveToCustomFolder,则必须在调用的event.completed属性中folderName指定邮件要移动到的文件夹的名称。 否则,该postProcessingAction属性将默认为moveToSpamFolder,并将报告的邮件移动到 Junk 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
注解
Outlook) (最低权限级别:读取项目
适用的 Outlook 模式:消息阅读
重要提示: 如果在用户从预处理对话框中选择“报告”选项后,在调用中event.completed配置 commandId “和contextData” 选项以打开任务窗格,则不会向用户显示后处理对话框。 即使在调用中event.completed指定了 ,showPostProcessingDialog此行为也适用。