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;
}
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.
Move the emails outside the SPAM
folder, forward them, or what have you, before interacting with them through the add-on.