V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
maogang39
V2EX  ›  Google

在 Apps Script 中获取当前时间插入邮件正文

  •  
  •   maogang39 · 2021-11-26 11:13:15 +08:00 · 1012 次点击
    这是一个创建于 875 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://developers.google.com/apps-script/reference/utilities/utilities#formatDate(Date,String,String) 中找到获取当前时间的方法

    var formattedDate = Utilities.formatDate(new Date(), "GMT+8", "yyyy-MM-dd'T'HH:mm:ss'Z'"); Logger.log(formattedDate);

    如何将获取到的时间插入到如下的邮件的正文中,可以让每封邮件的内容都不一致。

    function fn() {

    MailApp.sendEmail("1******.1*******[email protected].com", "", "Hello, World!");

    MailApp.sendEmail("1******.1*******[email protected].com", "", "Hello, World!");

    }

    尝试过以下的方式,直接被 Google Apps Script 报错

    function fn() {

    var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'");

    Logger.log(formattedDate);

    MailApp.sendEmail({"1******.1*******[email protected].com", "", "body: Logger.getLog(),Hello, World!"});

    MailApp.sendEmail({"1******.1*******[email protected].com", "", "body: Logger.getLog(),Hello, World!"});

    }

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2781 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.