【发布时间】:2018-10-26 16:17:09
【问题描述】:
【问题讨论】:
标签: outlook office365 outlook-addin office-js office-addins
【问题讨论】:
标签: outlook office365 outlook-addin office-js office-addins
您可以在撰写时设置和获取消息的正文内容。生成包含您希望出现在消息正文中的用户输入的 HTML 表格。使用getAsync 函数检索当前消息正文内容。将您生成的表格添加/插入到消息正文中,并使用setAsync 函数将其设置回来。您也可以使用prependAsync 函数来操作消息正文。请在Get and set item data in a compose form in Outlook阅读更多信息。
【讨论】:
以下代码只是展示了如何工作(对于 3 个输入)。正如您在问题中看到的那样,我有一个按钮。现在我可以通过单击按钮将任务窗格中的输入值作为表格添加到消息正文中。
$("#btn1").click(function () {
Office.context.mailbox.item.body.getAsync(
"html",
{ asyncContext: "This is passed to the callback" },
function callback(result) {
Office.context.mailbox.item.body.setSelectedDataAsync(
'<table style = "background-color: red">' +
'<tr>' +
'<th>Shipment</th>' +
'<th>Payment</th>' +
'<th>Validity</th>' +
'</tr>' +
'<tr>' +
'<td>' + $("#shipmentText").val() + '</td>' +
'<td>' + $("#paymentText").val() + '</td>' +
'<td>' + $("#validityText").val() + '</td>' +
'</tr>' +
'</table>',
{ coercionType: Office.CoercionType.Html }
)
})
});
【讨论】: