我可以使用 Outlook 加载项将 table 添加到邮件正文中吗
Can I add a table into the message body with Outlook Add-in
我正在使用 Outlook 加载项。我有一个消息撰写形式的任务窗格,其中包括一些文本区域。是否可以将这些信息作为 table 添加到邮件正文中?
以下是我的部分任务面板...
您可以在撰写时设置和获取邮件的正文内容。生成 HTML table 填充您希望出现在邮件正文中的用户输入。使用 getAsync
function. Add/insert the table you have generated into message body and set it back by using setAsync
function. You may also use prependAsync
function to manipulate with message body. Please read more information at Get and set item data in a compose form in Outlook.
检索当前消息正文内容
下面的代码只是展示了如何工作(对于 3 个输入)。正如您在问题中看到的,我有一个按钮。现在我可以通过单击按钮将任务窗格中的输入值添加到消息正文中作为 table。
$("#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 }
)
})
});
我正在使用 Outlook 加载项。我有一个消息撰写形式的任务窗格,其中包括一些文本区域。是否可以将这些信息作为 table 添加到邮件正文中?
以下是我的部分任务面板...
您可以在撰写时设置和获取邮件的正文内容。生成 HTML table 填充您希望出现在邮件正文中的用户输入。使用 getAsync
function. Add/insert the table you have generated into message body and set it back by using setAsync
function. You may also use prependAsync
function to manipulate with message body. Please read more information at Get and set item data in a compose form in Outlook.
下面的代码只是展示了如何工作(对于 3 个输入)。正如您在问题中看到的,我有一个按钮。现在我可以通过单击按钮将任务窗格中的输入值添加到消息正文中作为 table。
$("#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 }
)
})
});