Office.CoercionTypeOptions interface
提供数据格式的选项。
注解
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/20-item-body/append-text-on-send.yaml
// This snippet appends text to the end of the message or appointment's body once it's sent.
const text = (document.getElementById("text-field") as HTMLInputElement).value;
// It's recommended to call getTypeAsync and pass its returned value to the options.coercionType parameter of the appendOnSendAsync call.
Office.context.mailbox.item.body.getTypeAsync((asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log("Action failed with error: " + asyncResult.error.message);
return;
}
const bodyFormat = asyncResult.value;
Office.context.mailbox.item.body.appendOnSendAsync(text, { coercionType: bodyFormat }, (asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log("Action failed with error: " + asyncResult.error.message);
return;
}
console.log(`"${text}" will be appended to the body once the message or appointment is sent. Send the mail item to test this feature.`);
});
});
属性
| coercion |
所需的数据格式。 |