Office 365 Javascript API:context.mailbox.item.attachments未定义

时间:2018-12-14 17:47:44

标签: office-js outlook-web-addins

在此处查看文档https://docs.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.7/office.context.mailbox.item#attachments-arrayattachmentdetailsjavascriptapioutlook17officeattachmentdetails

当我尝试按照文档访问附件时:

var _Item = Office.context.mailbox.item;
var outputString = "";

if (_Item.attachments.length > 0) {
  for (i = 0 ; i < _Item.attachments.length ; i++) {
    var _att = _Item.attachments[i];
    outputString += "<BR>" + i + ". Name: ";
    outputString += _att.name;
    outputString += "<BR>ID: " + _att.id;
    outputString += "<BR>contentType: " + _att.contentType;
    outputString += "<BR>size: " + _att.size;
    outputString += "<BR>attachmentType: " + _att.attachmentType;
    outputString += "<BR>isInline: " + _att.isInline;
  }
}

// Do something with outputString

返回的值不确定。

Output from running the code sample from the docs

该附件文件不是该文档页面中链接的“阻止的附件类型”列表中的类型。

请帮助我了解我在做什么错。正在从365存储库中当前可用的现有365加载项中,从我们访问Office 365 Javascript API的文件中调用代码。我们使用相同的JS API方法Office.context.mailbox.item

成功检索了同一电子邮件项目的“ to”,“ cc”和“ bcc”值后,便会立即在提供的屏幕截图中进行调用

1 个答案:

答案 0 :(得分:1)

RTFM-该方法仅在“读取”上下文中可用,而在“撰写”上下文中不可用。