Multiple emails selected messageMetadata.accessToken

柔情痞子 提交于 2019-12-18 09:44:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!