Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendEmail() {
- //setup function
- var ss = SpreadsheetApp.openById("1hKGe3F87qwMskKjzemilu8aH0V9mHyVJkH1lXLm8Feg");
- var ActiveSheet = ss.getSheetByName("FormCalculations");
- var StartRow = 2;
- var RowRange = ActiveSheet.getLastRow() - StartRow + 1;
- var WholeRange = ActiveSheet.getRange(StartRow,1,RowRange,118);
- var AllValues = WholeRange.getValues();
- var message = "";
- //iterate loop
- for (i in AllValues) {
- //set current row
- var CurrentRow = AllValues[i];
- //define column to check if sent (starts from "0" not "1")
- var EmailSent = CurrentRow[104];
- //if row has been sent, then continue to next iteration
- if (EmailSent == "sent")
- continue;
- //set HTML template for information
- message +=
- "<font size='5'><p>CPI - Criteria Personality Inventory</p></font>" +
- "<p><b>New form submission recieved:</b></p>" +
- "<table cellpadding='10' cellspacing='0' border='0' bgcolor='#eeeeee' valign='top' style='width:90%; max-width:700px;'>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b>Email:</b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'>" + CurrentRow[1] + "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b>Timestamp:</b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'>" + CurrentRow[0] + "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b><font color='#0000ff'>Extraversion:</font></b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'><B>" + CurrentRow[106] + "</B> out of 80<br><B><font color='#0000ff'>" + CurrentRow[112] + "</font></B>%<br><br>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='" + CurrentRow[112] + "%' height='6' style=''>" +
- "<tr><td width='100%' align='right'><B><font color='#0000ff'>∇</font></B></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='6' style='border:1px solid #222222; border-top:0px solid #222222;'>" +
- "<tr><td width='10%' style='border-left:0px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='16' style=''>" +
- "<tr><td width='50%' align='left'><font size='1' color='#999999'>Introverted</td><td width='50%' align='right'><font size='1' color='#999999'>Extroverted</td></tr>" +
- "</table>" +
- "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b><font color='#0000ff'>Agreeableness:</font></b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'><B>" + CurrentRow[107] + "</B> out of 80<br><B><font color='#0000ff'>" + CurrentRow[113] + "</font></B>%<br><br>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='" + CurrentRow[113] + "%' height='6' style=''>" +
- "<tr><td width='100%' align='right'><B><font color='#0000ff'>∇</font></B></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='6' style='border:1px solid #222222; border-top:0px solid #222222;'>" +
- "<tr><td width='10%' style='border-left:0px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='16' style=''>" +
- "<tr><td width='50%' align='left'><font size='1' color='#999999'>Not agreeable</td><td width='50%' align='right'><font size='1' color='#999999'>Agreeable</td></tr>" +
- "</table>" +
- "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b><font color='#0000ff'>Conscientiousness:</font></b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'><B>" + CurrentRow[108] + "</B> out of 80<br><B><font color='#0000ff'>" + CurrentRow[114] + "</font></B>%<br><br>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='" + CurrentRow[114] + "%' height='6' style=''>" +
- "<tr><td width='100%' align='right'><B><font color='#0000ff'>∇</font></B></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='6' style='border:1px solid #222222; border-top:0px solid #222222;'>" +
- "<tr><td width='10%' style='border-left:0px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='16' style=''>" +
- "<tr><td width='50%' align='left'><font size='1' color='#999999'>Not conscientious</td><td width='50%' align='right'><font size='1' color='#999999'>Conscientious</td></tr>" +
- "</table>" +
- "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b><font color='#0000ff'>Neuroticism:</font></b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'><B>" + CurrentRow[109] + "</B> out of 80<br><B><font color='#0000ff'>" + CurrentRow[115] + "</font></B>%<br><br>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='" + CurrentRow[115] + "%' height='6' style=''>" +
- "<tr><td width='100%' align='right'><B><font color='#0000ff'>∇</font></B></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='6' style='border:1px solid #222222; border-top:0px solid #222222;'>" +
- "<tr><td width='10%' style='border-left:0px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='16' style=''>" +
- "<tr><td width='50%' align='left'><font size='1' color='#999999'>Relaxed</td><td width='50%' align='right'><font size='1' color='#999999'>Neurotic</td></tr>" +
- "</table>" +
- "</td></tr>" +
- "<tr><td style='min-width:30%; border-top:1px solid #dddddd;'><b><font color='#0000ff'>Openness to experience:</font></b></td><td style='border-top:1px solid #dddddd;' bgcolor='#f8f8f8'><B>" + CurrentRow[110] + "</B> out of 80<br><B><font color='#0000ff'>" + CurrentRow[116] + "</font></B>%<br><br>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='" + CurrentRow[116] + "%' height='6' style=''>" +
- "<tr><td width='100%' align='right'><B><font color='#0000ff'>∇</font></B></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='6' style='border:1px solid #222222; border-top:0px solid #222222;'>" +
- "<tr><td width='10%' style='border-left:0px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td><td width='10%' style='border-left:1px solid #222222;'></td></tr>" +
- "</table>" +
- "<table cellpadding='0' cellspacing='0' border='0' valign='top' width='100%' height='16' style=''>" +
- "<tr><td width='50%' align='left'><font size='1' color='#999999'>Closed to experiences</td><td width='50%' align='right'><font size='1' color='#999999'>Open to experiences</td></tr>" +
- "</table>" +
- "</td></tr>" +
- "</table>" +
- "<br><br>" +
- "<p><b>Title: </b>" + CurrentRow[2] + "</p>" +
- "<p><b>Agency: </b>" + CurrentRow[3] + "</p>" +
- "<p><b>Summary: </b>" + CurrentRow[4] + "</p>" +
- "<p><b>Due: </b>" + CurrentRow[5] + "</p>" +
- "<p><b>Posted: </b>" + CurrentRow[6] + "</p>" +
- "<p><b>Total Funding: </b>" + CurrentRow[7] + "</p>" +
- "<p><b>Announcement Number: </b>" + CurrentRow[8] + "</p>" +
- "<p><b>Useful Links: </b>" + CurrentRow[9] + "</p><br><br>"
- ;
- //set the row to look at
- var setRow = parseInt(i) + StartRow;
- //mark row as "sent"
- ActiveSheet.getRange(setRow, 105).setValue("sent");
- }
- //define who to send grants to
- var SendTo = "steven@nuttersons.co.uk";
- //set subject line
- var Subject = "Pre-employment test email";
- //send the actual email
- MailApp.sendEmail({
- to: SendTo,
- cc: "",
- subject: Subject,
- htmlBody: message,
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement