Office.AsyncContextOptions interface

Bietet eine Option zum unveränderten Beibehalten von Kontextdaten beliebigen Typs zur Verwendung in einem Rückruf.

Hinweise

Verwendet von

Beispiele

// 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);
            });
        }
    }
}

Eigenschaften

asyncContext

Ein benutzerdefiniertes Element eines beliebigen Typs, das unverändert in der Eigenschaft des Objekts zurückgegeben wird, das asyncContextAsyncResult an einen Rückruf übergeben wird.

Details zur Eigenschaft

asyncContext

Ein benutzerdefiniertes Element eines beliebigen Typs, das unverändert in der Eigenschaft des Objekts zurückgegeben wird, das asyncContextAsyncResult an einen Rückruf übergeben wird.

asyncContext?: any

Eigenschaftswert

any