我需要使用Outlook Mail add-in
在outlook的主体上添加一些内容我是这样做的
function getBody(cb) {
Office.context.mailbox.item.body.getAsync(
"html",
{ asyncContext: "This is passed to the callback" },
function (result) {
cb(result.value);
});
}
function setBody(content, cb) {
Office.context.mailbox.item.body.setAsync(
content,
{ coercionType: Office.CoercionType.Html },
function (result2) {
cb(result2);
});
}
这是电话
getBody(function (body) {
setBody(body + " appended", function (r) {
log(JSON.stringify(r));
});
});
在Outlook网站中,这很好用。但在桌面客户端(Outlook 2016)中,这不起作用。
这是从桌面版
获取回调结果的原因{"value":"","status":"succeeded"}
这是获取网络版
的回调结果的原因{"value":null,"status":"succeeded"}
请帮助。
答案 0 :(得分:1)
找到一个解决方案,我只是在html字符串的末尾添加一个文本,这是一件很脏的事情。
function FormatBody(bodyContent, extraContent, callback) {
var domParser = new DOMParser();
var parsedHtml = domParser.parseFromString(bodyContent, "text/html");
$("body", parsedHtml).append("<div>" + extraContent + "</div>");
var changedString = (new XMLSerializer()).serializeToString(parsedHtml);
callback(changedString);
}
解析html字符串并附加我想要的标签。它解决了。 :)