Skip to content

Commit 8c9b185

Browse files
Feat/add sample emails generation (googleworkspace#515)
* Update appsscript.json Add scope required to get user's email * Create Samples.gs Added code to generate 3 sample emails * fix/Update gmail-sentiment-analysis/Samples.gs Co-authored-by: Vinay Vyas <[email protected]> --------- Co-authored-by: Vinay Vyas <[email protected]>
1 parent e1bfbea commit 8c9b185

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

gmail-sentiment-analysis/Samples.gs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
Copyright 2025 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/**
18+
* Create sample emails
19+
*/
20+
function generateSampleEmails() {
21+
// Get active user's email
22+
const userEmail = Session.getActiveUser().getEmail();
23+
24+
// Send emails
25+
GmailApp.sendEmail(
26+
userEmail,
27+
"Thank you for amazing service!",
28+
"Hi, I really enjoyed working with you. Thank you again!",
29+
{
30+
name: 'Customer A',
31+
},
32+
);
33+
34+
GmailApp.sendEmail(
35+
userEmail,
36+
"Request for information",
37+
"Hello, I need more information on your recent product launch. Thank you.",
38+
{
39+
name: 'Customer B',
40+
},
41+
);
42+
43+
GmailApp.sendEmail(
44+
userEmail,
45+
"Complaint!",
46+
"Hello, You are late in delivery, again. Please contact me ASAP before I cancel our subscription.",
47+
{
48+
name: 'Customer C',
49+
},
50+
);
51+
52+
console.log("Sample email generation completed.")
53+
}
54+
* Create sample emails
55+
*/
56+
function generateSampleEmails() {
57+
// Get active user's email
58+
var userEmail = Session.getActiveUser().getEmail();
59+
60+
// Send emails
61+
GmailApp.sendEmail(
62+
userEmail,
63+
"Thank you for amazing service!",
64+
"Hi, I really enjoyed working with you. Thank you again!",
65+
{
66+
name: 'Customer A',
67+
},
68+
);
69+
70+
GmailApp.sendEmail(
71+
userEmail,
72+
"Request for information",
73+
"Hello, I need more information on your recent product launch. Thank you.",
74+
{
75+
name: 'Customer B',
76+
},
77+
);
78+
79+
GmailApp.sendEmail(
80+
userEmail,
81+
"Complaint!",
82+
"Hello, You are late in delivery, again. Please contact me ASAP before I cancel our subscription.",
83+
{
84+
name: 'Customer C',
85+
},
86+
);
87+
88+
console.log("Sample email generation completed.")
89+
}

gmail-sentiment-analysis/appsscript.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"https://www.googleapis.com/auth/script.external_request",
55
"https://www.googleapis.com/auth/cloud-platform",
66
"https://www.googleapis.com/auth/script.locale",
7+
"https://www.googleapis.com/auth/userinfo.email",
78
"https://www.googleapis.com/auth/gmail.addons.execute",
89
"https://www.googleapis.com/auth/gmail.labels",
910
"https://www.googleapis.com/auth/gmail.modify"

0 commit comments

Comments
 (0)