-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
296 lines (281 loc) · 9.4 KB
/
app.js
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
const fs = require('fs');
var stream = fs.createReadStream("nucleya_users.csv");
const csv = require('fast-csv')
const sgmail = require('@sendgrid/mail');
//set up api for mail
sgmail.setApiKey(
'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'
);
let i = 1;
var csvStream = csv()
.on("data", async function(data){
let email = data[0]
await sendEmail(email)
})
.on("end", function(){
console.log("done");
});
stream.pipe(csvStream);
sendEmail = async (toEmail)=>{
const msg_send = {
to: toEmail,
from: '[email protected]',
subject: 'NASA Space Apps challenge',
// text:
// 'You are receiving this because you (or someone else) has registered your account.\n\n' +
// 'Please click on the following link, or paste this into your browser to complete the verfication process:\n\n' +
// 'http://' +
// host + '/' +
// route +
// '/' +
// token +
// '\n\n' +
// 'If you did not request this.\n'
html: `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Registration Successful</title>
<style type="text/css" rel="stylesheet" media="all">
/* Base ------------------------------ */
*:not(br):not(tr):not(html) {
font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
width: 100% !important;
height: 100%;
margin: 0;
line-height: 1.4;
background-color: #F5F7F9;
color: #839197;
-webkit-text-size-adjust: none;
}
a {
color: #414EF9;
}
/* Layout ------------------------------ */
.email-wrapper {
width: 100%;
margin: 0;
padding: 0;
background-color: #F5F7F9;
}
.email-content {
width: 100%;
margin: 0;
padding: 0;
}
/* Masthead ----------------------- */
.email-masthead {
padding: 25px 0;
text-align: center;
}
.email-masthead_logo {
max-width: 400px;
border: 0;
}
.email-masthead_name {
font-size: 16px;
font-weight: bold;
color: #839197;
text-decoration: none;
text-shadow: 0 1px 0 white;
}
/* Body ------------------------------ */
.email-body {
width: 100%;
margin: 0;
padding: 0;
border-top: 1px solid #E7EAEC;
border-bottom: 1px solid #E7EAEC;
background-color: #FFFFFF;
}
.email-body_inner {
width: 570px;
margin: 0 auto;
padding: 0;
}
.email-footer {
width: 570px;
margin: 0 auto;
padding: 0;
text-align: center;
}
.email-footer p {
color: #839197;
}
.body-action {
width: 100%;
margin: 30px auto;
padding: 0;
text-align: center;
}
.body-sub {
margin-top: 25px;
padding-top: 25px;
border-top: 1px solid #E7EAEC;
}
.content-cell {
padding: 35px;
}
.align-right {
text-align: right;
}
/* Type ------------------------------ */
h1 {
margin-top: 0;
color: #292E31;
font-size: 19px;
font-weight: bold;
text-align: left;
}
h2 {
margin-top: 0;
color: #292E31;
font-size: 16px;
font-weight: bold;
text-align: left;
}
h3 {
margin-top: 0;
color: #292E31;
font-size: 14px;
font-weight: bold;
text-align: left;
}
p {
margin-top: 0;
color: #839197;
font-size: 16px;
line-height: 1.5em;
text-align: left;
}
p.sub {
font-size: 12px;
}
p.center {
text-align: center;
}
/* Buttons ------------------------------ */
.button {
display: inline-block;
width: 200px;
background-color: #414EF9;
border-radius: 3px;
color: #ffffff;
font-size: 15px;
line-height: 45px;
text-align: center;
text-decoration: none;
-webkit-text-size-adjust: none;
mso-hide: all;
}
.button--green {
background-color: #28DB67;
}
.button--red {
background-color: #FF3665;
}
.button--blue {
background-color: #414EF9;
}
/*Media Queries ------------------------------ */
@media only screen and (max-width: 600px) {
.email-body_inner,
.email-footer {
width: 100% !important;
}
}
@media only screen and (max-width: 500px) {
.button {
width: 100% !important;
}
}
</style>
</head>
<body>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table class="email-content" width="100%" cellpadding="0" cellspacing="0">
<!-- Logo -->
<tr>
<td class="email-masthead">
<img src="https://ecell.org.in/assets/images/logosmall.png" height="110" width="230" alt="KIIT E-Cell Logo"><br><br>
<a class="email-masthead_name">NASA Space Apps challenge</a>
</td>
</tr>
<!-- Email Body -->
<tr>
<td class="email-body" width="100%">
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0">
<!-- Body content -->
<tr>
<td class="content-cell">
<h1>NASA Space Apps challenge</h1>
<p>
Hello.<br>
<b>Greetings from KIIT E-Cell!</b><br><br>
We are thrilled to have you on board for the NASA Space Apps challenge. We are ready for it and we hope you’re geared up too.<br><br>
You are requested to report at the <b>Seminar Hall, KIIT School of Biotechnology</b> tomorrow (17th August 2019) sharp at <b>7:45 AM</b><br><br>
The itinerary for the event can be found here : https://ecell.org.in/nasa/ILH%20Overflow.pdf<br><br>
Please fill out your information in the Google form provided below.<br>
https://forms.gle/W9pHMmVzwg8AHq2a8<br>
That’s it.<br>
You’re all set to go!<br><br>
All the best!
<br><br><br>
Regards,<br>
KIIT E-Cell.<br>
<br><br>
<b>NOTE: </b>This is a server generated email, do not reply to this email. For any queries contact us on <br>
1. [email protected] (General Queries)<br>
2. [email protected] (Technical Support)
<!-- Sub copy -->
<!-- <table class="body-sub">
<tr>
<td>
<p class="sub">If you’re having trouble clicking the button, copy and paste the URL below into your web browser.
</p>
<p class="sub"><a href="{{action_url}}">{{action_url}}</a></p>
</td>
</tr>
</table> -->
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0">
<tr>
<td class="content-cell">
<p class="sub center">
NASA Space Apps challenge<br>
Venue : Seminar Hall, KIIT School of Biotechnology<br>
Date : 17th August 2019<br>
Time : 7:45 AM
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>`
};
try {
await sgmail.send(msg_send);
console.log("sent",i++)
} catch (e) {
console.log(e)
}
}