Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var helper = require('sendgrid').mail;
- var sg = require('sendgrid')("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");
- var mail = new helper.Mail();
- var email = new helper.Email('cankoathanasios@gmail.com', 'Athanasios Canko');
- mail.setFrom(email);
- mail.setSubject('QR Code Attachment (PNG)');
- var content = new helper.Content('text/plain', 'Hello, this is a PNG version of the QR code screenshot.')
- mail.addContent(content);
- var attachment = new helper.Attachment();
- var file = fs.readFileSync(__dirname + "/screenshot.png");
- var base64File = new Buffer(file).toString('base64');
- attachment.setContent(base64File);
- attachment.setFilename('screenshot.png');
- attachment.setDisposition('attachment');
- mail.addAttachment(attachment);
- var object = [
- {email: "xxxxxxxxxxxxxxx@hotmail.com", name: "xxxxxx"},
- {email: "xxxxxxxxxxxxxxx@gmail.com", name: "xxxxxx"}
- ];
- for (var i = 0; i < object.length; i += 1) {
- var personalization = new helper.Personalization();
- email = new helper.Email(object[i].email, object[i].name);
- personalization.addTo(email);
- mail.addPersonalization(personalization);
- var request = sg.emptyRequest({
- method: 'POST',
- path: '/v3/mail/send',
- body: mail.toJSON(),
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement