-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisit_email_script.js
More file actions
177 lines (162 loc) · 8.2 KB
/
visit_email_script.js
File metadata and controls
177 lines (162 loc) · 8.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
function formSubmit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetName = ss.getSheetByName('Form Responses 1');
var timestamp = e.namedValues['Timestamp'][0];
var respondentEmailAddress = e.namedValues['Email Address'][0];
var respondentName = e.namedValues['Name'][0];
var respondentPhoneNumber = e.namedValues['Phone Number'][0];
var dateTimeSelection = e.namedValues['Date & Time Selection'][0];
var reasonForVisit = e.namedValues['Reason for Visit'][0];
//Tour variables
var tourInterest = e.namedValues['Tour Interest'][0];
Logger.log("tourInterest: " + tourInterest);
//New Member Orientation variables
var nmoInterest = e.namedValues['Membership Interest'][0];
var moneyAck = e.namedValues['Access Card Deposit Agreement'][0];
Logger.log("nmoInterest: " + nmoInterest);
//Other variables
var otherInterest = e.namedValues['Other Reason'][0];
Logger.log("otherInterest: " + otherInterest);
//email template for Admin notification
var toAdminEmailAdress = 'contact@pikespeakmakerspace.org';
var emailSubject = respondentName + '_' + reasonForVisit + '_Visit-Us';
var textBody =
'There is a new submission for your Visit Us Form!\n' +
'Form Details:\n';
if(reasonForVisit === 'Take A Tour') {
textBody +=
'Date/Time Submitted: ' + timestamp + '\n' +
'Submitted by: ' + respondentName + '\n' +
'Email: ' + respondentEmailAddress + '\n' +
'Phone Number: ' + respondentPhoneNumber + '\n' +
'Reason for visit: ' + reasonForVisit + '\n' +
'Date & Time: ' + dateTimeSelection + '\n' +
'Their interest in PPM: ' + tourInterest + '\n';
} else if (reasonForVisit === 'New Member Safety Orientation') {
textBody +=
'Date/Time Submitted: ' + timestamp + '\n' +
'Submitted by: ' + respondentName + '\n' +
'Email: ' + respondentEmailAddress + '\n' +
'Phone Number: ' + respondentPhoneNumber + '\n' +
'Reason for visit: ' + reasonForVisit + '\n' +
'Date & Time: ' + dateTimeSelection + '\n' +
'Their interest in PPM: ' + nmoInterest + '\n' +
'Money Ack Response: ' + moneyAck + '\n';
} else {
textBody +=
'Date/Time Submitted: ' + timestamp + '\n' +
'Submitted by: ' + respondentName + '\n' +
'Email: ' + respondentEmailAddress + '\n' +
'Phone Number: ' + respondentPhoneNumber + '\n' +
'Reason for visit: ' + reasonForVisit + '\n' +
'Date & Time: ' + dateTimeSelection + '\n' +
'Their interest in PPM: ' + otherInterest + '\n';
}
var htmlText =
'<h3>There is a new submission for your Visit Us Form!</h3>' +
'<h4>Form Details:</h4>';
if(reasonForVisit === 'Take A Tour') {
htmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Phone Number: ' + respondentPhoneNumber + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Their interest in PPM: ' + tourInterest + '</li>'
'</ul>';
} else if (reasonForVisit === 'New Member Safety Orientation') {
htmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Phone Number: ' + respondentPhoneNumber + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Their interest in PPM: ' + nmoInterest + '</li>' +
'<li>Money Ack Response: ' + moneyAck + '</li>'
'</ul>';
} else {
htmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Phone Number: ' + respondentPhoneNumber + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Their interest in PPM: ' + otherInterest + '</li>'
'</ul>';
}
var options = {
htmlBody: htmlText
}
//send email notification to Admin
GmailApp.sendEmail(toAdminEmailAdress, emailSubject, textBody, options);
//Email template to Respondent
var confirmationSubject = 'Confirmation of Your Visit to Pikes Peak Makerspace!';
var confirmationBody = 'The email requires HTML support. Please use a client that supports HTML';
var confirmationHtmlText =
'<h3>Below are the details of your visit with us!</h3>' +
'<h4>Visit Details:</h4>';
if(reasonForVisit === 'Take A Tour') {
confirmationHtmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Your interest in PPM: ' + tourInterest + '</li>'
'</ul>' +
'<br>';
} else if (reasonForVisit === 'New Member Safety Orientation') {
confirmationHtmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Your interest in PPM: ' + nmoInterest + '</li>' +
'<li>Money Ack Response: ' + moneyAck + '</li>'
'</ul>' +
'<br>';
} else {
confirmationHtmlText +=
'<ul>' +
'<li>Date/Time Submitted: ' + timestamp + '</li>' +
'<li>Submitted by: ' + respondentName + '</li>' +
'<li>Email: ' + respondentEmailAddress + '</li>' +
'<li>Reason for visit: ' + reasonForVisit + '</li>' +
'<li>Date & Time: ' + dateTimeSelection + '</li>' +
'<li>Your interest in PPM: ' + otherInterest + '</li>'
'</ul>' +
'<br>';
}
confirmationHtmlText +=
'<br>' +
'<h4>Need to Reschedule or Cancel?</h4>' +
'<p>If you need to change the date or time you have selected or you need to cancel your visit for any reason, you can reply off this email or call us directly.</p>' +
'<p>We work mainly on volunteers so no shows really hurt us! We kindly ask if you need to change or cancel your visit to please get in contact with us!</p>' +
'<br>' +
'<h4>Please Note!</h4>' +
'<p>Just as a reminder, there might be other community members joining you on your visit to us. Also, per the Colorado state-wide mandate, we kindly ask that you <strong>wear a mask</strong> during the entire duration of your visit.</p>' +
'<br>' +
'<p>We look forward to meeting you!</p>' +
'<br>' +
'<p><strong>Pikes Peak Makerspace</strong></p>' +
'<p>735 E Pikes Peak Ave</p>' +
'<p>Colorado Springs, CO 80903</p>' +
'<a href="tel:7194456253">719-445-MAKE (6253)</a>';
var options = {
htmlBody: confirmationHtmlText,
name: 'Pikes Peak Makerspace', //cannot be Contact Us. Gmail gets confused and sends over the respondent's confirmation as well to us
from: 'contact@pikespeakmakerspace.org',
replyTo: 'contact@pikespeakmakerspace.org'
}
//send email confirmation to Respondent
GmailApp.sendEmail(respondentEmailAddress, confirmationSubject, confirmationBody, options);
}