如何使用Google脚本使gmailapp发送函数更具可读性 [英] How do I make the gmailapp send function more readable using google scripts

查看:0
本文介绍了如何使用Google脚本使gmailapp发送函数更具可读性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    var question = itemResponse.getItem().getTitle();
    var answer = itemResponse.getResponse();
    message += (i + 1).toString() + '.<b> ' + question + '</b>:
 ' + answer  + '
';
   if(answer === 'English'){var send=1;}
   if(answer === 'Japanese'){var send=2;}

  var address1 = 'myemail@gmail.com'; //★Your Email Address
  var title1 = '【incoming】Notification';
  var title2 = '【incoming】Notification';

  var content = '確認してください。The form was submitted with the following contents.

' + question + message;

  const html = `
  content1
  content2
  content3`;
  const options = {
    'htmlBody': html.replace(/
/g, '<br>')
  }

  var option = {};
  option.from = "myemail@gmail.com";
  

  if(send === 1){var to1 = [address1];
  GmailApp.sendEmail(to1,  title1,  content, option);}

更新:此代码除粗体部分外均可用。

我该如何设置粗体部分?似乎只是弹出了html,而不是真正的粗体。

推荐答案

当然,您可以直接添加<br>

但简单地换行并在之后立即替换可能更具可读性。

  const html = `<b>title</b>
  content1
  content2
  content3`;
  const options = {
    'htmlBody': html.replace(/
/g, '<br>');
  }
  GmailApp.sendEmail("allmanagers@company.com",title,content,options);

这篇关于如何使用Google脚本使gmailapp发送函数更具可读性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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