1

I am working on an outlook addin which needs to get the attachments for the mail. I am using office.js and the following code to fetch the mail item.

        Office.onReady( () => {        
        currentMailItem = Office.context.mailbox.item;
        const subject = currentMailItem.subject; // works fine;
        const attachments = currentMailItem.attachments; 
        //returns empty array for gmail configured in outlook
        //----- more code  -------
        }

Everything works as expected for outlook mails. I am able to access the properties such as subject, cc , bcc etc for outlook mails. But when I configured gmail inside outlook in mac , it fails to fetch the gmail attachments. Rest of the details ( subject, cc etc ) are available for use.

Is there any limitation on attachments in gmail ? or am I missing some additional steps to access gmail attachments configured inside outlook mail in mac?

Ragnar
  • 13
  • 2

1 Answers1

0

Outlook web add-ins works for the Exchange accounts only. Non-exchange backed accounts are not supported.


Typically an array of AttachmentDetails objects is returned as the attachments property of an appointment or message item.

// The following code builds an HTML string with details
// of all attachments on the current item.
var item = Office.context.mailbox.item;
var outputString = "";

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

console.log(outputString);
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Is the limitation exists only for attachments? because I am able to access other properties like Office.context.mailbox.item.subject, Office.context.mailbox.item.to etc. But Office.context.mailbox.item.itemId is not available though. – Ragnar Aug 14 '21 at 13:46
  • It seems there is a bug, web add-ins should not be activated for IMAP (Gmail?) accounts. Have no idea why it works for other properties. – Eugene Astafiev Aug 14 '21 at 14:01
  • I'd suggest posting this to the OfficeJS repo on GitHub. – Eugene Astafiev Aug 14 '21 at 14:01
  • the addin option for gmail works only on outlook desktop in mac os. And that too if I explicitly add the addin file for gmail account ( using custom addin file browse option). If the addin is already added to outlook mail, it appears greyed out. Then I explicitly add the addin again to the gmail account using the browse option mentioned earlier. – Ragnar Aug 14 '21 at 14:08
  • Anyway as it is clear that the feature is not supported for gmail account, I will inform the client. Thanks. – Ragnar Aug 14 '21 at 14:11