Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Outlook邮件加载项API在web和Outlook客户端中的工作方式不同_Outlook_Outlook Addin_Office365api_Office Js - Fatal编程技术网

Outlook邮件加载项API在web和Outlook客户端中的工作方式不同

Outlook邮件加载项API在web和Outlook客户端中的工作方式不同,outlook,outlook-addin,office365api,office-js,Outlook,Outlook Addin,Office365api,Office Js,我需要使用 我是这样做的 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, c

我需要使用

我是这样做的

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));
    });
});
在OutlookWeb中,这可以正常工作。但在桌面客户端(Outlook 2016)中,这不起作用

这是从桌面版本获取回调结果的内容

{"value":"","status":"succeeded"}
这是从web版本获取回调结果的内容

{"value":null,"status":"succeeded"}

请帮助。

找到了一个解决方案,我只是在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);
}
函数FormatBody(bodyContent、extraContent、callback){
var domParser=新的domParser();
var parsedHtml=domParser.parseFromString(bodyContent,“text/html”);
$(“body”,parsedHtml).append(“+extraContent+”);
var changedString=(新的XMLSerializer()).serializeToString(parsedHtml);
回调(changedString);
}

解析html字符串并附加我想要的标记。问题解决了。:)

您好,我刚刚在最新版本的Outlook 2016中尝试了这段代码,但无法重新处理问题:Office.context.mailbox.item.body.getAsync(“text”,function(ar){var body=ar.value;Office.context.mailbox.item.body.setAsync(body+“added”);});你还可以重新编程吗?您正在运行什么版本的Outlook 2016?嗯。。这是不同的。。getAsync(“文本”)不是我需要的。我需要HTML格式的邮件正文内容。如果您接受自己的答案,将来阅读本文的人会更清楚解决方案是什么