Skip to content

Instantly share code, notes, and snippets.

@hiimivantang
Last active March 2, 2022 03:27
Show Gist options
  • Save hiimivantang/aef358b6c26715ee628920b43d1f5f61 to your computer and use it in GitHub Desktop.
Save hiimivantang/aef358b6c26715ee628920b43d1f5f61 to your computer and use it in GitHub Desktop.
Send confirmation email and invite
function sendEmail(e) {
var subject = "Confirmation Message"
var message = "Hello! this is a test email!"
var old_value = e.oldValue
var new_value = e.value
console.log(e.range.rowStart)
console.log(e.range.rowEnd)
console.log(e.range.columnStart)
console.log(e.range.columnEnd)
console.log(old_value)
console.log(new_value)
if(new_value != old_value){
GmailApp.sendEmail(new_value, subject, message)
}
}
function sendEmail(e) {
var name = e.namedValues["First Name"]
var email = e.namedValues["Email Address"]
var sessions = e.namedValues["Which session are you attending?"]
var subject = "Confirmation Message"
var message = "Hello " + name + ", \n\n" + "This is a confirmation message to let you know we received your form submission.\n\nYou have selected the following sessions:\n" + sessions.join('\n') + "\n\nHere's the zoom link for all sessions: <INSERT ZOOM LINK HERE>"
//GmailApp.sendEmail(email, subject, message)
GmailApp.sendEmail(email, subject, message, {cc: "cc1@email.com,cc2@email.com"})
add_guests_to_event(email,<EVENT_ID>)
}
function add_guests_to_event(email, eventId) {
let calendarId = 'primary'; // ID of calendar containing event
var event = Calendar.Events.get(calendarId, eventId);
var attendees = event.attendees;
attendees.push({email: email});
var resource = { attendees: attendees };
var args = { sendUpdates: "all" };
Calendar.Events.patch(resource, calendarId, eventId, args);
}
@hiimivantang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment