Calendar events are tricky because different email clients handle these differently. Nodemailer uses the same style as Gmail for attaching calendar files which should ensure maximum compatibility. If you want to attach a calendar event to your email then you can use the message option icalEvent:
icalEvent – an object to define calendar event
You can use modules like ical-generator to generate the actual calendar file content, Nodemailer acts as a transport layer only and does not generate the event file structure.
let content = 'BEGIN:VCALENDAR\r\nPRODID:-//ACME/DesktopCalendar//EN\r\nMETHOD:REQUEST\r\n...';
let message = {
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Appointment',
text: 'Please see the attached appointment',
icalEvent: {
filename: 'invitation.ics',
method: 'request',
content: content
}
};
Event data is loaded from the provided file and attached to the message.
let message = {
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Appointment',
text: 'Please see the attached appointment',
icalEvent: {
method: 'PUBLISH',
path: '/path/to/file'
}
};
Event data is downloaded from the provided URL and attached to the message as regular calendar file.
let message = {
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Appointment',
text: 'Please see the attached appointment',
icalEvent: {
method: 'CANCEL',
href: 'http://www.example.com/events?event=123'
}
};