Question

I have a google form that is collecting information about users. As a confirmation of the data being entered into the form, I have a google script run on the Form Submit event that would send a copy of the responses to the user who submitted the data.

Recently, I've created an mvc 4 application to analyze the data as well as for sending emails to the users. I've been wanting to also now incorporate my mvc application to send the confirmation email to my users, but i'm unsure how to do this.

I've looked at the UrlFetchApp and I have a hunch i have to the following logic in my google script:

function sendHttpPost() {
   var payload = {
    "fieldOne" : "value for field one",
    "fieldTwo" : "value for field two",
   };

   var data = {
    "method" : "post",
    "payload" : payload
   };

   var myWebsite = "http://example.com/GoogleForm/SendConfirmationEmail"

   UrlFetchApp.fetch(myWebsite, data);
}

What i'm unsure is how I am suppose to access this data with my Mvc application? In my GoogleForm Controller, do i just create a SendConfirmationEmail method? What would be my parameter?

Was it helpful?

Solution

Your mvc controller should look like this :

public class GoogleFormController : Controller
{

    [HttpPost]
    public ActionResult SendConfirmationEmail(FormData formData)
    {
        // Send email. See http://aboutcode.net/postal/

        // I'm assuming you're returning json.
        return Json(formData);
    }

    public class FormData
    {
        public string fieldOne { get; set; }
        public string fieldTwo { get; set; }
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top