1

I want to set up auto-reply emails using scripts. We're currently using Canned Responses but the emails we're responding to just changed their setup so instead of sending the reply to the sender, we need to send it to the reply-to address. I think Google scripts may be the way to do that.

We have a filter that checks sender and a few words in the subject line. If those match, the canned response is sent. I'd like to duplicate this with Google script so that the from address can be our regular address and it can be sent to the reply-to address rather than the sender address. I've got a start below but am not sure how to ensure it only does this once for emails and I'd also like to star the thread afterwards. My attempts produce errors :) The script below works but will do it over and over, it seems.

function RespondEmail(e) {

  //send response email
  var threads = GmailApp.search("from:sender@messages.homeaway.com subject:Inquiry,'VRBO.com #5885'");
  for (var i = 0; i < threads.length; i++) {
    threads[i].reply("", {
      htmlBody: "<p><b>Thank you for contacting us</P>"
      });
  }
  • Sorry, script doesn't post well. Maybe there's a trick to that as I see others that look good. – Harp Mar 19 '15 at 6:29
  • Indent the script lines with four spaces (or use the { } button in the toolbar), and it will be formatted as code. – Vidar S. Ramdal Mar 19 '15 at 12:41

Your Answer

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

Browse other questions tagged or ask your own question.