forked from nodemailer/nodemailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathical-event.js
48 lines (41 loc) · 1.4 KB
/
ical-event.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
/* eslint no-console: 0 */
'use strict';
/*
This example sends a message with an attached icalendar event
Attached calendar events inside mime message are formatted identically to
calendar events sent from office365, eg. a single alternative encoded in base64
*/
var nodemailer = require('../lib/nodemailer');
// Create a SMTP transporter object
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]',
pass: 'Nodemailer123'
},
logger: true, // log to console
debug: true // include SMTP traffic in the logs
});
// Message object
var message = {
from: '"Sender Name" <[email protected]>',
to: '"Receiver Name" <[email protected]>',
subject: 'Calendar invite',
text: 'This message contains a calendar event',
icalEvent: {
method: 'request',
// content can be a string, a buffer or a stream
// alternatively you could use `path` that points to a file or an url
content: 'BEGIN:VCALENDAR\r\nPRODID:-//ACME/DesktopCalendar//EN\r\nMETHOD:REQUEST\r\nVERSION:2.0\r\n...'
}
};
console.log('Sending Mail');
transporter.sendMail(message, function (error, info) {
if (error) {
console.log('Error occurred');
console.log(error.message);
return;
}
console.log('Message sent successfully!');
console.log('Server responded with "%s"', info.response);
});