Google脚本仅转发具有大附件的收件箱

时间:2018-09-13 12:56:26

标签: google-apps-script gmail

我正在数据库中查找,找不到正在寻找的内容 我正在寻找一个仅转发Gmail收件箱中的新邮件的脚本。 我试图修改这个脚本。

function RespondEmail() {

  //send response email
  var threads = GmailApp.search("to:be01acd@pf.cofep.be is:unread");
  var subject = "";
  var msg = "";
  var c = 0; // will be used to count the messages in each thread
  var t = "";
  var attachment = "";
  var forwarded = "";

  for (var i = 0; i < 5 /*threads.length*/ ; i++) { 
    // I set 'i' to 3 so that you can test the function on your 3 most recent unread emails.
    // to use it on all your unread email, remove the 3 and remove the /* and */ signs.                   

    t = threads[i]; // I wanted to avoid repetition of "threads[i]" for the next 2 lines haha
    c = t.getMessageCount() - 1;
    msg = t.getMessages()[c];
    forwarded = msg.getBody(); // that is the body of the message we are forwarding.

    subject = msg.getSubject();
    attachment = msg.getAttachments();

    msg.forward("destination@gmail.com", {
      replyTo: "origin@gmail.com",
      subject: "TPS report status of [" + subject + "]", // customizes the subject
      htmlBody: "<br><br>" //adds your message to the body
        +
        "<div style='text-align: center;'>---------- Doorgestuurd bericht Gmail ----------</div><br>" + forwarded, //centers
      attachments: attachment
    });
    t.markRead(); // mark each forwarded thread as read, one by one

  }
}

但是失败了,我添加了label:inbox,它在线程数上阻塞了。 此外,此收件箱还会收到带有大附件的邮件。 并在有附件时阻止该脚本。

有人可以帮我吗?

亲切问候 奈杰尔。

0 个答案:

没有答案