当我尝试为垃圾邮件文件夹中的邮件激活插件时,它告诉我“垃圾邮件和可疑邮件不能用于推荐的内容或操作。” 我如何使它工作?
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;
}