【发布时间】:2020-08-27 16:44:09
【问题描述】:
我想创建一个与 Outlook 2016 兼容的加载项,它只是将正则表达式匹配替换为超链接。我的主要问题是我不知道如何访问消息正文。有没有我可以查看的示例项目?
这是我的 manifest.xml
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="OrderNumber" RegExValue="N\d{5}" PropertyName="BodyAsPlaintext"/>
</Rule>
这是我的 javascript
export async function run() {
Office.context.mailbox.item.body.getAsync(
"text",
{ asyncContext: "This is passed to the callback" },
function callback(result) {
const r = /N\d{5}/;
var allMatches = result.value.match(r);
if (allMatches) {
JSON.stringify(allMatches, null, 2);
} else {
//allMatches = "All matches was null";
}
for (var i = allMatches.length - 1; i >= 0; i--) {
document.getElementById("item-subject").innerHTML += "<b>Order ID's:</b> <br/>" + "<a href='https://www.test.com.au/admin/order/vieworder?id=" + allMatches[i] + "'>" + allMatches[i] + "</a><br>";
}
// document.getElementById("item-subject").innerHTML = "<b>Order ID's:</b> <br/>" + "<a href='https://www.test.com/admin/order/vieworder?id='" + allMatches + ">" + allMatches + "</a>";
});
主要是可行的解决方案
【问题讨论】:
标签: outlook office365 office-js outlook-addin