outlook - Outlook Javascript API - 添加以用链接替换正则表达式匹配
问题描述
我想创建一个与 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>";
});
主要是工作解决方案
解决方案
这对您有用吗,您似乎可以像这样访问它:
Office.context.mailbox.item.body.getAsync('text', function bodyCallback(result) {
console.log('value:', result.value)
});
https://docs.microsoft.com/en-us/javascript/api/outlook/office.body?view=outlook-js-preview
推荐阅读
- r - 从 R Shiny 中的反应输入中保存绘图时出现问题
- python - 登录异步函数时如何使用 request_id?
- javascript - 如何在使用 bitbucket 时修复节点 js 错误
- java - 从满足特定模式的字符串中获取表达式
- python - 用于数据帧转换的 pandas wide_long vs (stack and melt)
- delphi - Delphi 7启动时打开一个cmd
- android - 未解决的对 DaggerComponent 的引用
- typescript - 如何正确标准化对象?
- browser - 有没有办法在 Oculus 浏览器上访问本地文件系统?
- excel - 如何加快删除大型 Excel 文件中的工作表?