Office.DisplayedSubject interface
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
提供在阅读模式下临时设置邮件主题中显示的内容的方法。
方法
| set |
暂时在阅读模式下设置邮件主题中显示的内容。 设置的内容将保持可见,直到用户切换到其他消息或关闭当前消息的窗口。 |
| set |
暂时在阅读模式下设置邮件主题中显示的内容。 设置的内容将保持可见,直到用户切换到其他消息或关闭当前消息的窗口。 |
方法详细信息
setAsync(data, options, callback)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
暂时在阅读模式下设置邮件主题中显示的内容。 设置的内容将保持可见,直到用户切换到其他消息或关闭当前消息的窗口。
setAsync(data: string, options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;
参数
- data
-
string
要临时显示在邮件主题中的字符串。 字符串大小限制为 255 个字符。
- options
- Office.AsyncContextOptions
包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。
- callback
-
(asyncResult: Office.AsyncResult<void>) => void
可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。
asyncResult.error 属性中将提供遇到的所有错误。
返回
void
注解
最低权限级别: 读取/写入项目
适用的 Outlook 模式:消息阅读
重要说明:
如果多个实施
setAsync的加载项同时运行,则完成setAsync操作的最后一个加载项设置的内容将显示在“主题”字段中。该方法设置
setAsync的内容仅在用户查看项目时显示。 它不会缓存在 Outlook 中,也不会与其他 Outlook 客户端同步。如果在通话
setAsync后保存消息,则原始主题将显示在已保存的项目中。多封选定的邮件不支持此
setAsync方法。
setAsync(data, callback)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
暂时在阅读模式下设置邮件主题中显示的内容。 设置的内容将保持可见,直到用户切换到其他消息或关闭当前消息的窗口。
setAsync(data: string, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;
参数
- data
-
string
要临时显示在邮件主题中的字符串。 字符串大小限制为 255 个字符。
- callback
-
(asyncResult: Office.AsyncResult<void>) => void
可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。
asyncResult.error 属性中将提供遇到的所有错误。
返回
void
注解
最低权限级别: 读取/写入项目
适用的 Outlook 模式:消息阅读
重要说明:
如果多个实施
setAsync的加载项同时运行,则完成setAsync操作的最后一个加载项设置的内容将显示在“主题”字段中。该方法设置
setAsync的内容仅在用户查看项目时显示。 它不会缓存在 Outlook 中,也不会与其他 Outlook 客户端同步。如果在通话
setAsync后保存消息,则原始主题将显示在已保存的项目中。多封选定的邮件不支持此
setAsync方法。
示例
// 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 subject field 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 subjectText = (document.getElementById("subject-text-field") as HTMLInputElement).value;
Office.context.mailbox.item.display.subject.setAsync(subjectText, (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 subject field.");
});