0

Here is my script for forwarding emails to another inbox. However, now I want to only send emails that are unread with attachments to one email and then if no attachment to a different email. Can someone help me? I believe I would have to put something in the gmailapp.search about attachments, but I can't figure it out. I'm very green around the ears with this.

function AutoForward() {

  //send response email
  var threads = GmailApp.search("to:br@345.com is:unread,is:attachment=true");
  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 < 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("a@1234.com", {
  replyTo: "mail@abc.com",
  
  //htmlBody: "" //adds your message to the body
    //+
    //"<div style='text-align: center;'>---------- Forwarded message ----------</div><br>" + forwarded, //centers
  attachments: attachment
});
  t.markRead(); // mark each forwarded thread as read, one by one
  }
}
-1

Google couldn't verify that this account belongs to you. I lost my phone and forgot my Gmail account password. My account is jawadavenger526@gmail.com. I enabled two step verification code security. Bus didn't and any recover email.i got first verification code on my phone number but second verification otp code Google send to jawadavenger526@gmail.com .This account jawadavenger526@gmail.com is very imported for me .I have many personal data and all contacts save on my this Google account. I'm real owner of this jawadavenger526@gmail.com account. Please help me to reset my Gmail account password. I can't access my Gmail account..I'm in so trouble enter image description hereenter image description hereenter image description hereenter image description here

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.