Office.AddinCommands.Event interface

オブジェクトは Event 、関数コマンド ボタンによって呼び出されるアドイン関数にパラメーターとして渡されます。 オブジェクトを使用すると、アドインは、クリックされたボタンを識別し、処理が完了したことを Office アプリケーションに通知できます。

注釈

Excel、Word、PowerPoint でのサポートについては、「アドイン コマンド要件セット」を参照してください。

Outlook のサポート情報の概要を次に示します。

[ API セット: メールボックス 1.3 ]

サポート情報の詳細については、「 アドイン コマンド要件セット 」を参照してください。

最小アクセス許可レベル (Outlook): 制限あり

適用できる Outlook モード: 新規作成または読み取り

プロパティ

source

この関数の呼び出しをトリガーしたコントロールに関する情報。

メソッド

completed(options)

アドインの処理が完了し、自動的に閉じられることを示します。

このメソッドは、次によって呼び出された関数の末尾で呼び出す必要があります。

  • 関数コマンド ボタン (つまり、 属性が にExecuteFunction設定されている Action> 要素で<定義されたxsi:typeアドイン コマンド)。

  • Outlook の送信時アドインのイベント拡張ポイントで定義されたイベント。 たとえば、 ItemSend イベントです。

プロパティの詳細

source

この関数の呼び出しをトリガーしたコントロールに関する情報。

source:Source;

プロパティ値

注釈

Outlook のサポート情報の概要を次に示します。

[ API セット: メールボックス 1.3 ]

最小アクセス許可レベル: 制限

適用できる Outlook モード: 新規作成または読み取り

// In this example, consider a button defined in an add-in manifest.
// The following is the XML manifest definition. Below it is the Teams 
// manifest (preview) definition.
//
//<Control xsi:type="Button" id="eventTestButton">
//    <Label resid="eventButtonLabel" />
//    <Tooltip resid="eventButtonTooltip" />
//    <Supertip>
//        <Title resid="eventSuperTipTitle" />
//        <Description resid="eventSuperTipDescription" />
//    </Supertip>
//    <Icon>
//        <bt:Image size="16" resid="blue-icon-16" />
//        <bt:Image size="32" resid="blue-icon-32" />
//        <bt:Image size="80" resid="blue-icon-80" />
//    </Icon>
//    <Action xsi:type="ExecuteFunction">
//        <FunctionName>testEventObject</FunctionName>
//    </Action>
//</Control>
//
// The Teams manifest (preview) definition is the following.
// Ellipses("...") indicate omitted properties.
//
//     "extensions": [
//         {
//             ...
//             "runtimes": [
//                 {
//                  "id": "CommandsRuntime",
//                  "type": "general",
//                  "code": {
//                      "page": "https://localhost:3000/commands.html",
//                      "script": "https://localhost:3000/commands.js"
//                  },
//                  "lifetime": "short",
//                  "actions": [
//                      {
//                          "id": "testEventObject",
//                          "type": "executeFunction",
//                          "displayName": "testEventObject"
//                      }
//                  ]
//              }
//             ],
//             "ribbons": [
//                 {
//                     ...
//                     "tabs": [
//                         ...
//                         "groups": [
//                             ...
//                             "controls": [
//                                 {
//                                      "id": "eventTestButton",
//                                      "type": "button",
//                                      "label": "Perform an action",
//                                      "icons": [
//                                          {
//                                              "size": 16,
//                                              "file": "https://localhost:3000/assets/blue-icon-16.png"
//                                          },
//                                          {
//                                              "size": 32,
//                                              "file": "https://localhost:3000/assets/blue-icon-32.png"
//                                          },
//                                          {
//                                              "size": 80,
//                                              "file": "https://localhost:3000/assets/blue-icon-80.png"
//                                          }
//                                      ],
//                                      "supertip": {
//                                          "title": "Perform an action",
//                                          "description": "Perform an action when clicked."
//                                      },
//                                      "actionId": "testEventObject"
//                                  }
//                             ]
//                         ]
//                     ]                           
//                 }
//             ]
//         }
//     ]



// The button has an id set to "eventTestButton", and will invoke
// the testEventObject function defined in the add-in.
// That function looks like this:
function testEventObject(event) {
    // The event object implements the Event interface.

    // This value will be "eventTestButton".
    const buttonId = event.source.id;

    // Signal to the host app that processing is complete.
    event.completed();
}
// Function is used by two buttons:
// button1 and button2
function multiButton (event) {
    // Check which button was clicked.
    const buttonId = event.source.id;

    if (buttonId === 'button1') {
        doButton1Action();
    } else {
        doButton2Action();
    }

    event.completed();
}

メソッドの詳細

completed(options)

アドインの処理が完了し、自動的に閉じられることを示します。

このメソッドは、次によって呼び出された関数の末尾で呼び出す必要があります。

  • 関数コマンド ボタン (つまり、 属性が にExecuteFunction設定されている Action> 要素で<定義されたxsi:typeアドイン コマンド)。

  • Outlook の送信時アドインのイベント拡張ポイントで定義されたイベント。 たとえば、 ItemSend イベントです。

completed(options?: EventCompletedOptions): void;

パラメーター

options
Office.AddinCommands.EventCompletedOptions

オプション。 イベントの処理が完了したときに Outlook で送信時アドインの動作を指定する ItemSend オブジェクト。

戻り値

void

注釈

Outlook のサポート情報の概要を次に示します。

[ API セット: メールボックス 1.3 ]

最小アクセス許可レベル: 制限

適用できる Outlook モード: 新規作成または読み取り

重要: パラメーターは options送信時機能を実装する Outlook アドインにのみ適用されます。 メールボックス 1.8 で導入されました。

// For the following example, the processItem function is
// defined in the FunctionFile referenced from the add-in manifest,
// and maps to the FunctionName of the action in the associated button control.
function processItem(event) {
    // Do some processing.

    event.completed();
}
// In this example, the checkMessage function was registered as an event handler for ItemSend.
function checkMessage(event) {
    // Get the item being sent.
    const outgoingMsg = Office.context.mailbox.item;

    // Check if subject contains "BLOCK".
    outgoingMsg.subject.getAsync(function (result) {
        // Subject is in `result.value`.
        // If search term "BLOCK" is found, don't send the message.
        const notFound = -1;
        const allowEvent = (result.value.indexOf('BLOCK') === notFound);
        event.completed({ allowEvent: allowEvent });
    });
}