【问题标题】:append hidden content to meeting body in outlook using office js使用 office js 将隐藏内容附加到 Outlook 中的会议正文
【发布时间】: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


【解决方案1】:

以下是使用以下代码插入隐藏内容的示例。内容隐藏在 Outlook 2016、OWA 和 Outlook for Android 中。如果内容在其他电子邮件客户端中被视为纯文本,它可能仍会显示。

var content = 
"<!--[if !mso 9]><!-->"+
'<div class="hidden" style="display:none;max-height:0px;overflow:hidden;">'+
"CONTENT HERE THAT YOU WANT TO HIDE"+
"</div>"+
"<!--<![endif]-->";

Office.context.mailbox.item.body.setSelectedDataAsync("Hello World! " + content, function (asyncResult) {
  if (asyncResult.status == "failed") {
    console.log("Action failed with error: " + asyncResult.error.message);
  }
});

Source

【讨论】:

  • 我最近添加了 '
    SECRET TEXT
    ' 它被隐藏了在男孩中,但它显示在 Outlook 客户端的邮件列表预览部分中。有没有办法隐藏在那里? @Outlook 加载项团队 - MSFT
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-02
  • 1970-01-01
  • 2014-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多