Get subject, body and attachment info from Compose UI in gmail addon

185 views
Skip to first unread message

Sanket Dasgupta

unread,
May 30, 2019, 2:21:36 PM5/30/19
to Google Apps Script Community

I have this gmail addon which has a composeTrigger defined in appscript.json like this.

    "composeTrigger": {
      "selectActions": [
        {
          "text": "ComposeTrigger",
          "runFunction": "composeTrigger"
        }
      ],
      "draftAccess": "METADATA"
    },

In Main.js (or any other file) I have defined composeTrigger as:

function composeTrigger(event) {
    Logger.info(event.draftMetadata)
}

Now this draftMetadata only contains details of recipients (to, cc, bcc).

I want to access the subject, body and attachments also, but I have been unable to do so.

It's easy to access them when a mail is opened, from event.messsageMetadata, but event.messageMetadata is not available on the compose trigger callback.

Eric Koleda

unread,
May 30, 2019, 4:03:14 PM5/30/19
to Google Apps Script Community
At the moment you can only retrieve that limited set of metadata, not the subject or message body. You can find or file a feature request to allow for more access here:


- Eric

nilesh ghadshi

unread,
Jun 4, 2019, 9:10:47 AM6/4/19
to Google Apps Script Community
Is there another way to get draft email data on the compose trigger callback?

Romain Vialard

unread,
Jun 4, 2019, 9:27:39 AM6/4/19
to Google Apps Script Community
No. In the meantime you could try to use the list of recipients to find the corresponding draft (ie get the list of recipients, get all drafts, loop through all drafts and check if the recipients in a specific draft match the list of recipients you received from the compose trigger callback). But you will need an additional authorization scope for that (global read access on the user inbox).
Reply all
Reply to author
Forward
0 new messages