Question

Please excuse my possibly "lame" question here. I have searched everywhere and have not been able to find a solution.

Google forms -

I have one form that collects two email addresses. I need to have each email entered into the form receive a "unique" response when the form is submitted.

Below is an example of the code I've been "trying" to make work. (Where I only get the latter email to send)

I thank you in advance for your time.

Oliver

// this would be the first email sent to e.values[3] - the first email on the form 
function formSubmitReply(e) {
    var userEmail = e.values[3];
    MailApp.sendEmail(
        userEmail,
        "Help Desk Ticket1",
        "Thanks for submitting your issue. \n\nWe'll start " +
        "working on it as soon as possible. \n\nHelp Desk",
        {name:"Help Desk"}
    );
}

// this would be the second email sent to e.values[4] - the second email on the form 
function formSubmitReply(e) {
    var userEmail = e.values[4];
    MailApp.sendEmail(
        userEmail,
        "Help Desk Ticket - FYI form is sent",
        "The form a has been submitted. \n\nWe need to start " +
        "working on it as soon as possible. \n\nThe Reger Group",
        {name:"The Reger Group"}
    );
}
Was it helpful?

Solution

This is a blind shot (haven't tested), but here is my guess: you are creating the same function twice, thus the second replaces the first one. Functions are unique, if you can only have one function as callback of the form submission, you should adapt it to do everything you need within the one function call.

Here's what you could do:

// Sends distinct messages for each recipient
function formSubmitReply(e) {
    // First mail recipient and message
    MailApp.sendEmail(
        e.values[3],
        "Help Desk Ticket1",
        "Thanks for submitting your issue. \n\nWe'll start " +
        "working on it as soon as possible. \n\nHelp Desk",
        {name:"Help Desk"}
    );

    // Second mail recipient and message
    MailApp.sendEmail(
        e.values[4],
        "Help Desk Ticket - FYI form is sent",
        "The form a has been submitted. \n\nWe need to start " +
        "working on it as soon as possible. \n\nThe Reger Group",
        {name:"The Reger Group"}
    );
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top