Office.NotificationMessageAction interface

通知消息的操作定义。

注解

[ API set: Mailbox 1.10 ]

最低权限级别读取项

适用的 Outlook 模式:撰写或阅读

重要提示:在现代Outlook 网页版中NotificationMessageAction,对象仅在撰写模式下可用。

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml

// Adds an informational message with actions to the mail item.
const id = $("#notificationId").val().toString();

const itemId = Office.context.mailbox.item.itemId;
const details = {
  type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
  message: "This is an insight notification with id = " + id,
  icon: "icon1",
  actions: [
    {
      actionText: "Open insight",
      actionType: Office.MailboxEnums.ActionType.ShowTaskPane,
      // Identify whether the current mail item is in read or compose mode to set the appropriate commandId value.
      commandId: (itemId == undefined ? "PG.HelpCommand.Compose" : "PG.HelpCommand.Read"),
      contextData: { a: "aValue", b: "bValue" }
    }
  ]
};

Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);

属性

actionText

操作链接的文本。

actionType

要执行的操作类型。 ActionType.ShowTaskPane 是唯一受支持的操作。

commandId

清单中定义的按钮。

contextData

操作按钮需要传递给加载项的任何 JSON 数据。

属性详细信息

actionText

操作链接的文本。

actionText: string;

属性值

string

actionType

要执行的操作类型。 ActionType.ShowTaskPane 是唯一受支持的操作。

actionType: string | MailboxEnums.ActionType;

属性值

commandId

清单中定义的按钮。

commandId: string;

属性值

string

contextData

操作按钮需要传递给加载项的任何 JSON 数据。

contextData: any;

属性值

any

注解

重要说明

  • 在 Outlook on Windows 中, any 从版本 2402 (内部版本 17308.20000) 开始支持该类型。 在早期版本的 Outlook on Windows 中,仅 string 支持 类型。

  • 若要检索 JSON 数据,请调用 Office.context.mailboxitem.getInitializationContextAsync。 如果使用 创建 JSON 字符串 JSON.stringify() 并将其分配给 contextData 属性,则必须在检索该字符串后使用 JSON.parse() 分析该字符串。