问题
Is it possible to process multiple selected emails by an addon? The code from Google shows how to process only one selected email. I suppose 'e' would be some kind of array of accesstokens but I don't know how to access it.
function getContextualAddOn(e) {
var accessToken = e.messageMetadata.accessToken;
Logger.log("token:"+ accessToken);
GmailApp.setCurrentMessageAccessToken(accessToken);
var messageId = e.messageMetadata.messageId;
var card = createCard();
return [card.build()];
}
Thanks.
回答1:
Your Apps Script code never runs on the client device, where the messages are selected in the Gmail UI - it runs on Google's servers. You can't access UI information from add-ons (there's no GmailApp.getSelectedThreads(), CardService.getActiveEmails(), etc.). You are only able to access the opened message / draft, and others in the same thread (or mailbox, depending on your add-on's scopes).
The event object received by your triggered callback function will only have a single access token. Until additional manifest triggers are added (currently only contextual and compose exist), this won't change.
As this is not Google, no one here can tell you if or when other triggers may or may not be added. You best bet is to request the feature.
来源:https://stackoverflow.com/questions/52470800/multiple-emails-selected-messagemetadata-accesstoken