Мы реализовали функцию создания черновиков, используя Составить действия .
Однако предмет искажен.
Если объект あいうえお
, это будет Re: BDFHJ
.
Я хочу предотвратить искаженные символы.
этот код.
Code.js
function buildCard (e) {
var card = CardService.newCardBuilder();
card.setHeader(CardService.newCardHeader().setTitle("タイトル"));
var section = CardService.newCardSection();
var composeAction = CardService.newAction()
.setFunctionName('createReplyDraft');
var composeButton = CardService.newTextButton()
.setText('Compose Reply')
.setComposeAction(composeAction, CardService.ComposedEmailType.REPLY_AS_DRAFT);
section.addWidget(composeButton);
card.addSection(section);
return card.build();
}
/**
* Creates a draft email (with an attachment and inline image)
* as a reply to an existing message.
* @param {Object} e data passed by the compose action.
* @return {ComposeActionResponse}
*/
function createReplyDraft(e) {
// Activate temporary Gmail add-on scopes, in this case to allow
// a reply to be drafted.
var accessToken = e.messageMetadata.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
// Creates a draft reply.
var messageId = e.messageMetadata.messageId;
var message = GmailApp.getMessageById(messageId);
var draft = message.createDraftReply('あいうえお'); //There is no problem with body.
// Return a built draft response. This causes Gmail to present a
// compose window to the user, pre-filled with the content specified
// above.
return CardService.newComposeActionResponseBuilder()
.setGmailDraft(draft).build();
}
appsscript.json
{
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.readonly"
],
"gmail": {
"name": "Gmail Add-on Quickstart",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/2x/bookmark_black_24dp.png",
"contextualTriggers": [{
"unconditional": {
},
"onTriggerFunction": "buildCard"
}],
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#4285F4",
"secondaryColor": "#4285F4"
},
"oauthScopes":[
"https://mail.google.com/",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/script.external_request"]
}
этот поток.
step1.
У тебя есть почта.
![enter image description here](https://i.stack.imgur.com/Ql1kX.png)
step2.
Нажмите Compose Reply
![enter image description here](https://i.stack.imgur.com/QCRuH.png)
step3.
Изменить тему.
![enter image description here](https://i.stack.imgur.com/FYuRk.png)
step4.
Тема искажена.
![enter image description here](https://i.stack.imgur.com/m3HB8.png)