Reputation: 109
Following the documentation here https://learn.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.7/office.context.mailbox.item#attachments-arrayattachmentdetailsjavascriptapioutlook17officeattachmentdetails
When I try to access the attachments as per the documentation:
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
the returned value is undefined.
The attached file is not of a type on the blocked attachments type list linked in that documentation page.
Please help me understand what I'm doing wrong. The code is being called from an existing 365 add-in that is currently available on the 365 store, from a file where we access the Office 365 Javascript API. The call that I made in the provided screenshot happens directly after we successfully retrieve the 'to', 'cc', and 'bcc' values for the same email item, using the same JS API method Office.context.mailbox.item
Upvotes: 1
Views: 561
Reputation: 109
RTFM - the method is only available in the "Read" context, not in the "Compose" context.
Upvotes: 2