I'm a complete script beginner.
I successfully set up the following script by searching on the Internet.
I'd like to add another source here.
GmailApp.sendEmail(address, title, body, {
from: 'email address', name: 'sender'
});
I tried the above description by trial and error, but
There is no basic syntax concept, so the error failed to set it up properly.
I would be very happy if anyone could tell me.Thank you for your cooperation.
I would like to add it to the script below and set it up successfully.
function sendMailGoogleForm(){
Logger.log('sendMailGoogleForm()debug start');
//------------------------------------------------------------
// Configuration Area From Here
//------------------------------------------------------------
// Subject, Body, Footer
var subject="[Acceptance slip]";
var body
= This is ●●.\n"
+ "Thank you very much for your recent application.\n"
+ "We look forward to seeing you on the day.\n\n"
+ "\n\n"
+ "----------------------------------------------------------------------\n";
var footer
= US>"----------------------------------------------------------------\n"
+ "";
// Specifying the Input Column Name
var NAME_COL_NAME = 'Name';
varMAIL_COL_NAME = 'Mail Address';
var address="";
// Mail To
var admin="event@events.●●.jp";// Administrator (required)
varcc="; // Cc:
var bcc = admin; // Bcc:
var reply=admin;// Reply-To:
var to = "; // To: (The address of the input person is automatically entered)
//------------------------------------------------------------
// Configuration Area Up to here
//------------------------------------------------------------
try{
// Working with Spreadsheets
varsheet=SpreadsheetApp.getActiveSheet();
varrows=sheet.getLastRow();
varcols=sheet.getLastColumn();
varrg=sheet.getDataRange();
Logger.log("rows="+rows+"cols="+cols);
// Email subject/text creation and destination email address acquisition
for(vari=1;i<=cols;i++){
varcol_name = rg.getCell(1,i).getValue(); // Column Name
varcol_value=rg.getCell(rows, i).getValue(); // Input value
body+="["+col_name+"]\n";
body+=col_value+"\n\n";
if(col_name===NAME_COL_NAME){
body=col_value+"Dear\n\n"+body;
}
if(col_name===MAIL_COL_NAME){
to=col_value;
}
}
body+=footer;
// Destination Options
var options={};
if(cc)options.cc =cc;
if(bcc) options.bcc = bcc;
if(reply)options.replyTo=reply;
// sending an e-mail
if(to){
MailApp.sendEmail(to, subject, body, options);
} else {
MailApp.sendEmail(admin, "[Failure] No email address specified in Google form", body);
}
}catch(e){
MailApp.sendEmail(admin, "[Failure] Error sending mail from Google form", e.message);
}
}
For GmailApp sendMail options from
You must be registered with the alias or surrogate sender of the running G account.
I think it's a security reason.If you can specify your favorite email address, it's spam.
I recently created a similar tool.
The proxy sender sends an email from Google to the designated email address and
You can configure it by entering the authentication code written there.
For aliases, why don't you refer to this?
https://www.ka-net.org/blog/?p=4441
Either way, open the running account's Gmail in your browser and
If the sender of the new mail can be selected, it will be successful.
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.