Office.AsyncContextOptions interface

提供一个选项,用于保留任何类型的上下文数据(不变),以便在回调中使用。

注解

示例

// The following example gets the attachment contents of the
// current mail item being composed in Outlook.
function getAttachmentContentCompose() {
    const item = Office.context.mailbox.item;
    const options: Office.AsyncContextOptions = { asyncContext: { currentItem: item } };
    item.getAttachmentsAsync(options, callback);

    function callback(result) {
        if (result.status === Office.AsyncResultStatus.Failed) {
            console.log(result.error.message);
            return;
        }

        if (result.value.length <= 0) {
            console.log("Mail item has no attachments.");
            return;
        }

        const currentItem = result.asyncContext.currentItem;
        for (let i = 0; i < result.value.length; i++) {
            currentItem.getAttachmentContentAsync(result.value[i].id, (asyncResult) => {
                if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                    console.log(asyncResult.error.message);
                    return;
                }

                console.log(asyncResult.value.content);
            });
        }
    }
}

属性

asyncContext

在传递给回调的 AsyncResult 对象的 属性中asyncContext返回的任何类型的用户定义项,未更改。

属性详细信息

asyncContext

在传递给回调的 AsyncResult 对象的 属性中asyncContext返回的任何类型的用户定义项,未更改。

asyncContext?: any

属性值

any