The following script is supposed to use to send automatic response emails using Gmail's canned response feature while avoiding “+canned.response” added to the username in the reply:

function RespondEmail(e) {

      // set response mail
      var response = GmailApp.getMessageById('153c2b9e7d4ac8c4');
      var responsebody = response.getBody();

      //send response email
      var aliases = GmailApp.getAliases()
      var threads = GmailApp.search("label:respondemail label:unread");
      for (var i = 0; i < threads.length; i++) {
        threads[i].reply("", {htmlBody: responsebody, from: aliases[0]});}

      // mark all as read
      var threads = GmailApp.search("label:respondemail label:unread");

The script can be set to search for emails by setting a time based interval trigger. If an email with the label respondemail is found, which could have been assigned to it through the Gmail filter feature, an automatic answer will be sent.

However, no alias is picked up (aliases is just an empty string). It works inserting an email address instead of this string, though. Is it possible to have your name shown as sender, instead of just your email address, which will happen when you send an email manually?

  • Do you have an email message with Id 1452e6aef2c5c09f ? To get the Id of a message that is the first in a thread, open it in Gmail: the Id is the part at the end of URL, after /#inbox/
    – user79865
    Apr 1, 2016 at 0:41
  • No, I fixed it now, thanks! However, another problem showed up, see the last paragraph above.
    – Jeff
    Apr 1, 2016 at 10:18

1 Answer 1


Solved completely! I had to use the name parameter as well:

threads[i].reply("", {htmlBody: responsebody, from: '[email protected]', name: 'Someone Blabla'});}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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