I want to know if there is an application that can allow an interaction between Google Mail and a Google Sheet.
I explain myself :
I receive many e-mail from online forms and all the email are similar with the inormations about the customer I have to contact. I want to receive all the form into a Google Sheets that I can manage like a CRM.
Thank you for your help.
Regards,
Steve
There are services that can assist with this and you can use custom scripts also. It can also depend on what type of platform you're using for the contact form.
IFTTT | Zapier | Script
If the data is correctly formatted this one is an easy script to do exaclty that.
In google sheets, Tool >Script Editor >
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(' List');
var last = sheet.getLastRow();
for(var i=2;i<last+1;i++){}
var firstName = sheet.getRange(i, 1).getValue();
var email = sheet.getRange(i, 4).getValue(); // the second value is the column numbers , from left to right 1 to all
var message = 'Hola '+firstName+', message'; // Replace "Message" with your meesage and if you need to break lines use /n at the start of the new line
GmailApp.sendEmail(email, 'MPFC Schedule Assistant Bot',message);
}
Related
I want the script to send the created html email template email.html to the person who last submitted the form.
Below is the success message I get in the console:
Below is the actual email that is received by the person who submits the form:
The email.html is formatted correctly and appears perfectly when sent manually.
I hope this is reprex enough.
EDIT: Maybe it's easier if I include the code
function sendEmail () {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow();
var data = ss.getRange(lr,3);
var email = data.getValue();
var message = HtmlService.createTemplateFromFile('email');
var subject = "Test Subject"
GmailApp.sendEmail(email,subject, message);
}
It's not clear why you are using HtmlService.createTemplateFromFile, but from the image it's clear there at least one error, the script misses two methods:
HtmlService.HtmlTemplate.evaluate() to evaluate the Templated HTML
HtmlService.HtmlOutput.getContent() to get the HTML from the HtmlService.HtmlOutput object returned by the previous method.
Another option that looks to be an error is the use of GmailApp.sendEmail(string,string,string) method, as the third parameter should be a string to be used as the email plain text content. If you want to pass HTML, instead use GmailApp.sendEmail(string,string,string, Object)
Related
Emailing Google Sheet range (with or without formatting) as a HTML table in a Gmail message
Sending an email in HTML and plain with a Gmail Apps Script
Google script inject html into html email
References
https://developers.google.com/apps-script/guides/html
https://developers.google.com/apps-script/guides/html/templates
https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String)
Here's the code I'm using to send an email. It works perfectly when the email goes to Gmail (it sends four short tables with a line break between each one). However, when it goes to Outlook the second table (1,16) doesn't have new lines between the table entries while the other three tables still do (I don't know if it's related to those values specifically since the tables are identical in format). I understand there's probably some difference between email services, but is there a simple way to have the emails be consistent with new lines when arriving in both places? Thank you.
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheet4=ss.getSheetByName('Copy');
var emailAddress = sheet4.getRange(2,12).getValue();
var subject = sheet4.getRange(2,13).getValue();
var message = sheet4.getRange(1,15,sheet4.getRange(31,15).getValues(),1).getValues().join('\n')+
sheet4.getRange(1,14,3,1).getValues().join('\n')+
sheet4.getRange(1,16,sheet4.getRange(31,16).getValues(),1).getValues().join('\n')+
sheet4.getRange(1,14,3,1).getValues().join('\n')+
sheet4.getRange(1,17,sheet4.getRange(31,17).getValues(),1).getValues().join('\n')+
sheet4.getRange(1,14,3,1).getValues().join('\n')+
sheet4.getRange(1,18,sheet4.getRange(31,18).getValues(),1).getValues().join('\n');
MailApp.sendEmail(emailAddress, subject, message);
}
I'm starting a new project. I have to send a confirmation email when someone purchases a book with my Google Form. By now, I can send an email when you complete the form but I can't put the name of the buyer and the number of books in the email. F.ex : Hello "John", you gonna receive your "3" books in a week.
I've tried something like this :
function sendEmail(e) {
var formreponse = e.responses;
var itemreponse = formreponse.getItemResponses();
var number= itemreponse[5].getResponse(); //because it's in the 5th columns of the spread sheets
var name= itemreponse[3].getResponse();
And then I just write a simple code like this
var TextToSend = "blablabla" + name + " blabla" + number + ".";
GmailApp.sendEmail(emailTo, subject, TextToSend, options);
But I've got an error message:
Cannot read property 'responses' of undefined.
And I don't know why!
It's very frustrating for me not to be able to finish this simple task.
Issues:
When running this function manually, through the editor, no event object is passed, and so e is undefined. You should not run this function manually.
responses is not a valid Event property of Form submit triggers.
Solution:
Install an onFormSubmit trigger, either manually or programmatically, so that the function will run automatically when the Form is submitted, and e will be populated.
Change e.responses to e.response:
var formreponse = e.response;
Reference:
Event Objects > Google Forms events > Form submit
I have a simple goal, to open up an email (in Outlook 2016) with the To field configured for multiple recipients from a Windows 10 UWP app.
I tried 3 approaches
1) The recommended way, as demod in the UWP samples, using the EmailMessage
var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();
emailMessage.Body = "";
foreach (Person p in SelectedPeople)
{
if (string.IsNullOrEmpty(p.Email) == false)
{
var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(p.Email);
emailMessage.To.Add(emailRecipient);
}
}
await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage);
This results in an email window with the recipients seperate by commas which then do not resolve. Setting the option to allow comma seperators seemed like an answer, but it tuens out that doesn't work unless there is a space to seperate too?
2) Build a mailto:user1#work.com;user2#work.com URI and launch it.
var uri = new Uri("mailto:user1#work.com;user2#work.com");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
However, attempting to create URI with multiple recipeitns throws an exception that the URI hostname is invalid
3) Same as above but using the scheme mailto:?To=user1#work.com;user2#work.com
This is parsed correctly as a URI but on launch Outlook shows an empty recipient list. By way of testing, using CC= does show the recipients in the CC field
So, now I am stuck wondering how I can send an email to multiple recipients for a store app?
Late to the party, but someone linked this from another question..
Have you tied mailto:user1#work.com%3buser2#work.com
seems to work for me
I am using script editor in google spreadsheets to send an auto response email. However, I received Summary of failures notifications suggesting an invalid email: undefined (on the Mail.App line). I don't know how this error came about. Please help. Thanks so much.
function myFunction(e) {
var Nickname = e.values [2];
var email = e.values [10];
var subject = "Form Submitted"
var message =
"Thank you, " = + Nickname + ". Your response is accepted. You may want to check our website # iydsphilippines.weebly.com for registration payment details. Thanks and we hope to see you soon!";
MailApp.sendEmail(email, subject, message);
}
Here is a link to a copy of my spreadsheet.
<>
I'm no expert however I also had the same issue and by trial and error I have discovered what the problem is.
It seems that recently Google have "upgraded / changed" the way fields are evaluated.
If any fields are blank then problems arise and as your email field in column K (i.e. the 10th field counting the first as zero) and some of the others are blank it seems to get confused. Until Google fix this "undocumented feature" I have a workaround.
Move your Email column to nearer the beginning i.e. straight after the name for example but before any optional fields, then renumber it in the code and you should be OK.
Specifically in your example: Move Column K to be Column C and renumber "var email = e.values [10]" to be "var email = e.values [2]" That should do it.
Good Luck and let me know how you get on. From Lester in the UK