电子邮件中的空格 [英] Spaces in Email

查看:243
本文介绍了电子邮件中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个GSM Gmail插件,该插件将在撰写窗口中打开卡片并具有多个字段,然后将生成一个模板并将其添加到电子邮件中.我有几个包含HTML内容的变量,还有几个包含卡片中的字段的变量.我差不多完成了.我需要做的最后一件事是指定一个主题,每次都相同,并指定基于卡片中文本字段的收件人. 这是我的代码.我有2个文件,一个gs代码文件和一个json清单文件.

I am trying to build a GSM Gmail addon that will open a card in the compose window and have several fields and then will generate a template and add it to the email. I have several variables containing HTML content and several containing fields from the card. I have almost gotten that done. The last thing that I need to do is to specify a subject, that will be the same every time, and specify recipients that will be based on a text field in the card. Here is my code. I have 2 files, one gs code file, and one json manifest file.

Manifest.json:

Manifest.json:

{
  "timeZone": "America/Chicago",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "oauthScopes": ["https://www.googleapis.com/auth/gmail.addons.current.action.compose", "https://www.googleapis.com/auth/gmail.addons.current.message.readonly", "https://www.googleapis.com/auth/gmail.addons.execute", "https://www.googleapis.com/auth/script.locale"],
  "runtimeVersion": "V8",
  "addOns": {
    "common": {
      "name": "Review Published Email Template",
      "logoUrl": "https://goodbookreviews.page/Logo.png",
      "useLocaleFromApp": true,
      "universalActions": [{
        "label": "Book Review ",
        "openLink": "https://www.goodbookreviews.page"
      }]
    },
    "gmail": {
      "contextualTriggers": [{
        "unconditional": {
        },
        "onTriggerFunction": "onGmailMessage"
      }],
      "composeTrigger": {
        "selectActions": [{
          "text": "Use Template",
          "runFunction": "onGmailCompose"
        }],
        "draftAccess": "NONE"
      }
    }
  }
}

code.js:

function onGmailCompose(e) {
  console.log(e);
  var header = CardService.newCardHeader()
      .setTitle('Use Template')
      .setSubtitle('Use the template for sending an email after a review has been published.');
  // Create text input for entering the cat's message.
  var input = CardService.newTextInput()
      .setFieldName('email')
      .setTitle('Email')
      .setHint('What is the readers email address?');
  var input2 = CardService.newTextInput()
  .setFieldName('FName')
  .setTitle('First Name')
  .setHint('What is the readers first name?');
  var input3 = CardService.newTextInput()
  .setFieldName('BookTitle')
  .setTitle('Reviewed Book Title')
  .setHint('What is the title of the book reviewed?');
  var input4 = CardService.newTextInput()
  .setFieldName('BookAuthor')
  .setTitle('Reviewed Book Author')
  .setHint('Who is the author of the book reviewed?');
  // Create a button that inserts the cat image when pressed.
  var action = CardService.newAction()
      .setFunctionName('useTemplate');
  var button = CardService.newTextButton()
      .setText('Use Template')
      .setOnClickAction(action)
      .setTextButtonStyle(CardService.TextButtonStyle.FILLED);
  var buttonSet = CardService.newButtonSet()
      .addButton(button);
  // Assemble the widgets and return the card.
  var section = CardService.newCardSection()
      .addWidget(input)
      .addWidget(input2)
      .addWidget(input3)
      .addWidget(input4)
      .addWidget(buttonSet);
  var card = CardService.newCardBuilder()
      .setHeader(header)
      .addSection(section);
  return card.build();
}
function useTemplate(e) {
  console.log(e);
  var email = e.formInput.email;
  var FName = e.formInput.FName;
  var Title = e.formInput.BookTitle;
  var Author = e.formInput.BookAuthor;
  var now = new Date();
  var htmlIntro = '<p>Hello, </p>';
  var html2 = '<p> Thank you for writing a book review at <a href="https://www.goodbookreviews.page">Good Book Reviews</a> on</p>';
  var html3 = '<p>by</p>';
  var html4 = '<p>. You Review has been published to our site. Any personal information you included was NOT published, including first name, last name,  age, and email address. Only info you wrote about the book was published. You can see it right <a href="https://www.goodbookreviews.page./books-and-reviews/look-at-reviews"> here!</a> If you need anything else, feel free to contact us at support@goodbookreviews.page or reply to this email to contact us. <br> Happy Reading,<br> The Book Review Team</p>';
  var message = htmlIntro + FName + html2 + Title + html3 + Author + html4;
  var response = CardService.newUpdateDraftActionResponseBuilder()
  .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
                            .addUpdateContent(message, CardService.ContentType.MUTABLE_HTML)
                            .setUpdateType(CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
  .build();
  return response;
}
function onGmailMessage(e) {
  console.log(e);
  var header = CardService.newCardHeader()
  .setTitle('Unavailable')
  .setSubtitle('Open the compose window to use template');
  var card = CardService.newCardBuilder()
  .setHeader(header);
  return card.build();
}

有人可以告诉我该怎么做吗?谢谢!

Can someone please tell me how to do this? Thanks!

推荐答案

您的"p"标签会创建额外的换行符.尝试类似

Your "p" tags create extra newlines. Try something like

var htmlIntro = '<p>Hello, ';
var html2 = 'Thank you for writing a book review at <a href="https://www.goodbookreviews.page">Good Book Reviews</a> on ';
var html3 = ' by ';
var html4 = '. You Review has been published to our site. Any personal information you included was NOT published, including first name, last name,  age, and email address. Only info you wrote about the book was published. You can see it right <a href="https://www.goodbookreviews.page./books-and-reviews/look-at-reviews"> here!</a> If you need anything else, feel free to contact us at support@goodbookreviews.page or reply to this email to contact us. <br> Happy Reading,<br> The Book Review Team</p>';
var message = htmlIntro + FName + html2 + Title + html3 + Author + html4;

或者,如果您使用的是V8引擎,则更简单

Or, if you use V8 engine, even simpler

var message = `<p>Hello, ${FName} Thank you for writing a book review at Good Book Reviews on ${Title} by ${Author}. Your Review has been published to our site. Any personal information you included was NOT published, including first name, last name, age, and email address. Only info you wrote about the book was published. You can see it right here! If you need anything else, feel free to contact us at support@goodbookreviews.page or reply to this email to contact us.</p>
<br>
<p>Happy Reading,</p>
<br>
<p>The Book Review Team</p>
`

这篇关于电子邮件中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆