3

When I try to activate my add-on for a message in the SPAM folder it tells me "Spam and suspicious messages can’t be used for recommended content or actions." How do I make it work?

function getContextualAddOn(event) {
  var message = getCurrentMessage(event);

  var card = createCard(message);

  return [card.build()];
}

/**
 * Retrieves the current message given an action event object.
 * @param {Event} event Action event object
 * @return {Message}
 */
function getCurrentMessage(event) {
  var accessToken = event.messageMetadata.accessToken;
  var messageId = event.messageMetadata.messageId;
  GmailApp.setCurrentMessageAccessToken(accessToken);
  return GmailApp.getMessageById(messageId);
}

function createCard(message) {
  var emailFrom = message.getHeader("return-path-1");
  var card = CardService.newCardBuilder();
  card.setHeader(CardService.newCardHeader().setTitle("Forward e-mail"));
  
  var statusSection = CardService.newCardSection();
  statusSection.addWidget(CardService.newTextParagraph()
     .setText("<b>Sender: </b>" + emailFrom ));
  card.addSection(statusSection);
  
  var formArea = CardService.newCardSection();
  var widget = CardService.newTextInput()
    .setFieldName("forwardTo")
    .setTitle("To:");
  
  formArea.addWidget(widget);
  card.addSection(formArea);
  
  return card;
}
Rubén
  • 34,714
  • 9
  • 70
  • 166
Neal
  • 197
  • 1
  • 16

1 Answers1

1

Gmail add-ons cannot currently handle emails inside the SPAM folder.

There is an open Feature Request in Issue Tracker regarding this functionality:

I'd suggest you to star this issue, in order to prioritize it and to keep track of any updates.

Workarounds:

Move the emails outside the SPAM folder, forward them, or what have you, before interacting with them through the add-on.

Iamblichus
  • 18,540
  • 2
  • 11
  • 27
  • Thank you for the confirmation and link. I should have known. After all, Google doesn't allow you to filter messages by Return-Path or X-Forwarded-For email headers either. Why would they want you to get rid of SPAM?? – Neal Jul 21 '20 at 17:56