通過 Office 加載項將內容添加到 Outlook 電子郵件正文 (Adding content to an Outlook email body via an Office Add-In)


問題描述

通過 Office 加載項將內容添加到 Outlook 電子郵件正文 (Adding content to an Outlook email body via an Office Add‑In)

我創建了一個 Office 加載項,並希望將一些 html 內容添加到電子郵件正文中。這可行,但內容有所改變,因此我的 css 無法正常工作。出於某種原因,添加“x_”作為屬性的前綴(見圖)

圖像正文中渲染的 hmtl 部分

我正在使用Office.mailbox.item.body.setSelectedDataAsync 方法添加 html。

您可以在 GitHub 上找到代碼:https://github.com/genevangampelaere/OutlookTrelloAddIn


參考解法

方法 1:

I don't know why it's adding the x_ prefix, but the main problem is that you are setting css styles, not classes, and that should be in a style attribute not a class attribute.

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 });

方法 2:

Here is the answer from Microsoft in their add‑in documentation (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."

(by Gene VangampelaerelgaudViolaman)

參考文件

  1. Adding content to an Outlook email body via an Office Add‑In (CC BY‑SA 2.5/3.0/4.0)

#outlook #ms-office






相關問題

Outlook 2007/2010 中的 Vspace (Vspace in Outlook 2007/2010)

Outlook 2010 自動完成流(緩存的聯繫人) (Outlook 2010 autocomplete stream ( cached contacts))

如何格式化電子郵件中的字符串以便 Outlook 打印換行符? (How do I format a String in an email so Outlook will print the line breaks?)

通過 Office 加載項將內容添加到 Outlook 電子郵件正文 (Adding content to an Outlook email body via an Office Add-In)

Outlook Addin 中的 Recipient.Name 和 ExchangeUser.Name 有什麼區別? (What is the Difference Between Recipient.Name and ExchangeUser.Name in Outlook Addin?)

運行時錯誤,用於電子郵件自動化的 VBA EXCEL (Runtime Error, VBA EXCEL for email automation)

將 Crystal Reports 轉換為 HTML 並作為正文發送到我的郵件中 (Crystal Reports into HTML and sending in my mail as body)

通過 VBA 將格式化的電子郵件正文複製到新的 Word 文檔中並保留文本格式 (Copy formatted Email body into new Word document via VBA and keep the text formatting)

Outlook 在啟動時忽略加載項的 HKEY_LOCAL_MACHINE 條目 (Outlook ignoring HKEY_LOCAL_MACHINE entry for add-in on startup)

如何知道是否收到或發送了電子郵件? (How to know if an e-mail was received or sent?)

如何從 Excel 表格創建電子郵件? (How to create emails from Excel table?)

如何在 Outlook 正文中左對齊從 Excel 範圍創建的 HTML 表格? (How to Left-Align HTML Table, created from an Excel Range, in an Outlook Body?)







留言討論