V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
SamClip
V2EX  ›  Google

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

  •  
  •   SamClip · Nov 26, 2021 · 1527 views
    This topic created in 1613 days ago, the information mentioned may be changed or developed.

    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!"});

    }

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1014 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:04 · PVG 03:04 · LAX 12:04 · JFK 15:04
    ♥ Do have faith in what you're doing.