通过 Office 加载项将内容添加到 Outlook 电子邮件正文
Adding content to an Outlook email body via an Office Add-In
我创建了一个 Office 加载项,并想向电子邮件正文中添加一些 html 内容。这行得通,但内容有所改变,因此我的 css 无法正常工作。出于某种原因,添加 "x_" 作为属性的前缀(见图)
我正在使用 Office.mailbox.item.body.setSelectedDataAsync 方法添加 html。
您可以在 GitHub 上找到代码:https://github.com/genevangampelaere/OutlookTrelloAddIn
我不知道为什么要添加 x_ 前缀,但主要问题是您正在设置 css 样式,而不是 类,并且应该在 style
属性不是 class
属性。
Office.context.mailbox.item.body.setSelectedDataAsync("<div style=\"border-left-width: 2px;border-left-color: #0067A3;border-left-style: solid;padding-left: 10px;\"><h2>" + card.name + "</h2><div>" + card.desc + "</div></div>", { coercionType: Office.CoercionType.Html });
这是 Microsoft 在其加载项文档 (https://dev.office.com/reference/add-ins/outlook/1.5/Body) 中的回答。
"When working with HTML-formatted bodies, it is important to note that the Body.getAsync and Body.setAsync methods are not idempotent. The value returned from the getAsync method will not necessarily be exactly the same as the value that was passed in the setAsync method previously. The client may modify the value passed to setAsync in order to make it render efficiently with its rendering engine."
我创建了一个 Office 加载项,并想向电子邮件正文中添加一些 html 内容。这行得通,但内容有所改变,因此我的 css 无法正常工作。出于某种原因,添加 "x_" 作为属性的前缀(见图)
我正在使用 Office.mailbox.item.body.setSelectedDataAsync 方法添加 html。
您可以在 GitHub 上找到代码:https://github.com/genevangampelaere/OutlookTrelloAddIn
我不知道为什么要添加 x_ 前缀,但主要问题是您正在设置 css 样式,而不是 类,并且应该在 style
属性不是 class
属性。
Office.context.mailbox.item.body.setSelectedDataAsync("<div style=\"border-left-width: 2px;border-left-color: #0067A3;border-left-style: solid;padding-left: 10px;\"><h2>" + card.name + "</h2><div>" + card.desc + "</div></div>", { coercionType: Office.CoercionType.Html });
这是 Microsoft 在其加载项文档 (https://dev.office.com/reference/add-ins/outlook/1.5/Body) 中的回答。
"When working with HTML-formatted bodies, it is important to note that the Body.getAsync and Body.setAsync methods are not idempotent. The value returned from the getAsync method will not necessarily be exactly the same as the value that was passed in the setAsync method previously. The client may modify the value passed to setAsync in order to make it render efficiently with its rendering engine."