Gmail Auto-Replies Based on Message Content

Hello Amit,

I have just found your Digital Inspiration website and have just started to learn Google Apps Script.

I’m wondering if you can help me by pointing me at any examples of Google Apps Scripts that I could modify to do what I want.

I can first summarize this in one abstract statement – "use google apps script to generate an automatic response based on a well defined string in the content of a gmail message"

That’s the basic question. Here is the background on what I am doing and the reason I want to do the abstract statement above.

I have a specific problem that I am trying to solve. Let me describe the entire process I currently use to approve subscriptions to a Yahoo Group that I run (Unfortunately Yahoo Groups doesn’t support what I need to do, and so I’m looking to use some automated mail responder software add on to gmail to help me).

I regularly get email messages in my gmail inbox from people subscribing to a Yahoo Groups discussion list. Before I approve their subscription, I need to send them a questionnaire. Right now, I read every incoming subscription request, pick out their email message from the body of the subscription approval request I get from Yahoo, and compose a form letter which contains the questionnaire and send the message. When I get a response, if they qualify to be part of the discussion, I can then approve the subscription.

The is the step I wish to automate is the one where I get a message from Yahoo Groups asking me to approve the subscription. This message is not from the person subscribing, but rather from Yahoo. The email I need to send the questionnaire to is in the body of the incoming message and is on a line, such as:

Email address: abc.xyz <abc>

Right now, I pick out "abc.xyz <abc>" by hand and then compose a message to that address with a canned response which includes the questionnaire.

So if you can point me toward any existing scripts that do similar things I am a good enough programmer that I can figure out what to do.

Thank you.
Regards,

  • Canned responses in Gmail are a good solution but they’ll only send the reply to the sender.

    In this case, you can probably use regular expressions to extract the email address from the email message body (getBody().match(regex)) and, if it matches, reply to the person using the GmailApp.sendMail method of Google Apps script.

  • forsdick

    Amit,

    Thanks for your previous reply.

    Is there a way to add a button or link to gmail so I can invoke a Google App Script from the GMail window?

    And, is there a way in GApps Script to process multiple messages within GMail? I. E. select a set of messages and have a GApps Script be run on each of the messages in the set?

    All I need is an example of a similar script. I am happy to contribute what I come up with to your set of useful gmail GApps Scripts.

    Thanks.

    — Harry

  • You should explore the HTML service of Google Scripts for adding links in Gmail that invoke a server side script.

    Yes, scripts can process multiple messages from Gmail.

    var threads = GmailApp.search(“label:personal”, 0, 10);
    for (var i=0; i<threads.length; i++) {
    Logger.log(threads[i].getFirstMessageSubject());
    }

    See the Send to PDF snippet.

  • Seemon Shahin

    i need a gmail autoresponer with my mail