SamClip
V2EX  ›  Google

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

  •  
  •   SamClip · Nov 26, 2021 · 1576 views
    This topic created in 1635 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   ·   5283 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:43 · PVG 16:43 · LAX 01:43 · JFK 04:43
    ♥ Do have faith in what you're doing.