【发布时间】:2018-04-06 12:08:06
【问题描述】:
使用我的 Outlook 插件,我需要向会议正文添加一些隐藏数据(一些元数据)。我尝试将 display:none 样式添加到 html 元素但没有运气。有没有办法做到这一点?
下面是我设置正文内容的代码
function addWorkspaceToItemBody(textToAppend) {
var d = $q.defer();
var item = Office.context.mailbox.item;
item.body.getTypeAsync(
function (result) {
if (result.status == Office.AsyncResultStatus.Failed){
write(result.error.message);
}
else {
// Successfully got the type of item body.
// Set data of the appropriate type in body.
if (result.value == Office.MailboxEnums.BodyType.Html) {
// Body is of HTML type.
// Specify HTML in the coercionType parameter
// of setSelectedDataAsync.
item.body.setSelectedDataAsync(
'<p style="display:none">'+textToAppend+'<\p>',
{ coercionType: Office.CoercionType.Html,
asyncContext: { var3: 1, var4: 2 } },
function (asyncResult) {
if (asyncResult.status ==
Office.AsyncResultStatus.Failed){
d.reject(asyncResult.error.message);
}
else {
d.resolve(asyncResult)
// Successfully set data in item body.
// Do whatever appropriate for your scenario,
// using the arguments var3 and var4 as applicable.
}
});
}
else {
// Body is of text type.
item.body.setSelectedDataAsync(
"",
{ coercionType: Office.CoercionType.Text,
asyncContext: { var3: 1, var4: 2 } },
function (asyncResult) {
if (asyncResult.status ==
Office.AsyncResultStatus.Failed){
d.reject(asyncResult.error.message);
}
else {
d.resolve(asyncResult)
// Successfully set data in item body.
// Do whatever appropriate for your scenario,
// using the arguments var3 and var4 as applicable.
}
});
}
}
});
return d.promise;
}
【问题讨论】:
-
您能分享一下您的场景吗?通过添加隐藏的内容,您是否打算在接收端对其进行处理?
-
是的,在我的插件中,我有一个下拉列表,用户在下拉列表中选择一些值并单击提交按钮,我需要发送该选择的值并在接收端使用它。
-
如果我理解正确,您是否打算在单击提交按钮后将隐藏的 html 元素添加到会议正文中?
-
是的,这就是我想做的。我尝试添加没有链接文本的锚标记,它适用于 web 版本的 Outlook,但从 Windows Outlook 应用程序中它不起作用。
-
您针对哪些客户端和版本(例如 Outlook 2013、Outlook 2016 等)?
标签: outlook-addin office-js outlook-web-addins