I'm trying to set up google scripts to send emails automatically - google-apps-script

I'm trying to create a script for a sheet that can send an email when an order has been reviewed.
It should only send it if column Column G has a specific Value like "Approved", "Rejected" or "Have questions".
Here's the file to work on: https://docs.google.com/spreadsheets/d/1BYzydUDgI1ZrjKip1KecMh-ntbTyLRlN3sRKI3EZZbw/edit?resourcekey#gid=599960808
The email content should look like:
Subject: Order request status: 'ColumnG'
Hi 'ColumnB',
We received your request for 'ColumnD'
Status: 'ColumnG'
More Details: 'ColumnH'
-Admin
Email should be sent to Column E.

Related

How to send email of specific Google Sheet data after Responded submit Google Form Answer

i would like to ask about how to send email of specific Google Sheet data after Responded submit Google Form Answer
the google sheet data is collected from multiple sheets and using conditional IF or VLOOKUP or maybe QUERY
i have more than 2 sheet, just say 4 sheets (can be more)
Sheet 1 : Database
Sheet 2 : Doc X
Sheet 3 : Doc Y
Sheet 4 : Doc Z
the detail is like this
https://i.stack.imgur.com/77qBM.png
so i want to make script that do sending email automatically after responded submit the google form
in this case it would send email to JKL#GMAIL.COM
because of the secret code is ID-004
the email would be something like this
Hi here is your ID list :
DOCX-003
DOCY-003
DOCZ-003
if the data still 1 row ( ABC#GMAIL.COM ID-001 )
then it would send this
Hi here is your ID list :
DOCX-001
DOCY-001
thanks you for your insight

Change a specific status after a few days from a date

I have a Google sheet where our agents updated about the emails being sent and the responses received. If they send an email out, they will update the status as "Sent". If they get a response for the email sent, they will change the status to "Client not interested" or "send more details" or some other statuses based on the reply received from the drop-down.
We enter the date in a column by when we sent the email. From that day we wait for three days to get a reply and if it was not received, then the "sent" status should disappear from cell wherever it appears in the status column.
Basically if we did not receive any reply after 3 days from the date of sending the email, the status set as "Sent", should disappear which we understand as "no reply received" for the email sent.
I am not skilled with scripts. I need your help to add a script for this as we will be sending many emails everyday and automating this particular thing will help us a lot. Thanks in advance.
Best
Joe
Most likely you will want to utilize an onEdit trigger. ref
And you will have to set up data validation for The Status Column and that can be accomplished through the Data Menu.
Most well writtten onEdit functions are similar to this:
function onEdit(e) {//e is population by the triggers event object
const sh = e.range.getSheet();
if( sh.getName() == "your sheet name" && e.columnStart == "column number of status column" && e.range.rowStart > "header row" ) {
//enter the rest of your code in here and all other edits on this and other pages will not enter this code and be returned as quickly as possible
}
}
After you've learned a little more about how the onEdit work you may wish to reconsidered how you would like things to work because a good design is typically a compromise between the user interface and the complexity of the software.

How can I reply a going thread to a specific group of emails?

I am using Google App Scripts to search and reply to a going emails.
Let's say I can use GmailApp.search to search a thread by subject already and I want to reply to the first search result
I want to reply to: and cc: to specific people every time search and reply this going email. Like: to: a#gmail.com + cc: b#gmail.com, c#gmail.com.
Now I am using thread[0].replyAll because I don't know how to do as above. But always it reply to all the people of the last message of the going email ( even including me in to the cc or me in the to: if I am the last one doing message of the total email)
var subjectsearch =brandname+"/ SAMBU"+"/ MATERIAL REQUEST/ ROUND "+round+'/ '+subjectname;
var threads = GmailApp.search('subject:('+subjectsearch+')');
if (threads.length>0){
threads[0].replyAll(messagePrefix,{from:"kevin#sambu.sewing.co.kr",htmlBody: message, })
first message
If I replyall it will look like this, I dont want to send to me but always a specific to: and cc: if I want

On edit trigger for send email function

I am trying to create a script and/or trigger that will send an email to a small group of users anytime a value is entered into cells within a specific column of a google sheet. I am able to get the send email function to work properly but all the triggers I have attached the current script that is functional as far as sending the email, I just need a way to trigger it via script or the actual triggers wizard.
I tried an on edit trigger but I do not think I was using it correctly OR it doesn't have the permissions needed to send an email.
function myFunction() {// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("EmailScript").getRange("B2");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var message = 'L&F cash amount entered!'; // Second column
var subject = 'L&F Cash';
MailApp.sendEmail(emailAddress, subject, message);
}
I want for an email to be sent anytime a value is entered into any cell within column D.
Any help is greatly appreciated.

Email notification to a specific user based on value in a cell

I'm about to create a Google Form which will export to a Google Sheet. I want to be able to send an email notification to a specific email address (from a list of addresses) based on an answer (which would be in a cell in column C) when the form is submitted.
Example:
UserA answers first question which is required: "What region are you from?"
based on that answer, I want an email to be sent to a specific email address from a list of addresses.
If UserA answers South East an email will be sent to Bob#acme.com
If UserA answers North, an email will be sent to Betty#acme.com
If UserA answers West, an email will be sent to Frank#acme.com
Thanks.
You can use an object and test the incoming value for the Col C.
Example:
var emails ={"South East": "Mail1#some.com,
"North": "Mail2#some.com",
...
}
And then assuming the column c goes like..
var colC = e.namedValues['xxx'];
var recipient = emails[colC];
This is just the general methodology. You can also use switch statement.
You should validate the input before proceeding to confirm if the user value is valid.
Plenty of tuts available on email notification on form submit.