Office.DisplayedBody interface
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Provides a method to temporarily set the content displayed in the body of a message in read mode.
Methods
| set |
Temporarily sets the content displayed in the body of a message in read mode. The set content remains visible until the user switches to a different message or closes the window of the current message. |
| set |
Temporarily sets the content displayed in the body of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message. |
Method Details
setAsync(data, options, callback)
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Temporarily sets the content displayed in the body of a message in read mode. The set content remains visible until the user switches to a different message or closes the window of the current message.
setAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;
Parameters
- data
-
string
The string to be temporarily displayed in the body of a message. The string is limited to 1,000,000 characters.
An object literal that contains one or more of the following properties:- asyncContext: Developers can provide any object they wish to access in the callback function. coercionType: The format of the data to be temporarily displayed. The string in the data parameter will be converted to this format.
- callback
-
(asyncResult: Office.AsyncResult<void>) => void
Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. Any errors encountered will be provided in the asyncResult.error property.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Recommended: Call Office.context.mailbox.item.body.getTypeAsync, then pass the returned value to the options.coercionType parameter.
Important:
If multiple add-ins that implement
setAsyncrun simultaneously, the content set by the last add-in that completes thesetAsyncoperation is displayed in the body.The content set by the
setAsyncmethod is only displayed while the user is viewing the item. It isn't cached in Outlook and doesn't sync with other Outlook clients.If you save a message after calling
setAsync, the original contents of the message body appear in the saved item.The
setAsyncmethod isn't supported on multiple selected messages.
setAsync(data, callback)
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Temporarily sets the content displayed in the body of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message.
setAsync(data: string, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;
Parameters
- data
-
string
The string to be temporarily displayed in the body of a message. The string is limited to 1,000,000 characters.
- callback
-
(asyncResult: Office.AsyncResult<void>) => void
Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. Any errors encountered will be provided in the asyncResult.error property.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Important:
If multiple add-ins that implement
setAsyncrun simultaneously, the content set by the last add-in that completes thesetAsyncoperation is displayed in the body.The content set by the
setAsyncmethod is only displayed while the user is viewing the item. It isn't cached in Outlook and doesn't sync with other Outlook clients.If you save a message after calling
setAsync, the original contents of the message body appear in the saved item.The
setAsyncmethod isn't supported on multiple selected messages.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml
// This snippet temporarily sets the content displayed in the body of a message in read mode.
// The set content will remain visible until the user switches to a different message in the Reading Pane or closes the window of the current message.
const bodyText = (document.getElementById("body-text-field") as HTMLInputElement).value;
Office.context.mailbox.item.display.body.setAsync(bodyText, (asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log(`Action failed with error: ${asyncResult.error.message}`);
return;
}
console.log("Temporarily set the content displayed in the body.");
});