I want to send calendar invite. I'm using Nodemailer
and ical-generator
to generate ical file. Everything working fine but email doesn't add invite to the calendar automatically instead I get an option to Add to calendar
. But I want email to directly add event to the calendar.
This is how email looks like -
My code looks like this.
This code converts to ical file and it is being used with Nodemailer
icalEvent to send it.
const content = ical({
domain: 'google.com',
method: 'PUBLISH',
prodId: '//Google Inc//Google Calendar 70.9054//EN',
timezone: 'Australia/Brisbane',
scale: 'GREGORIAN',
events: [
{
start: moment(),
status: 'CONFIRMED',
end: moment().add(1, 'hour'),
summary: 'Calendar invite test',
transparency: 'OPAQUE',
organizer: {
name: 'Organiser name',
email: 'ttt@gmail.com',
mailto: 'ttt@gmail.com'
},
location: 'Zoom',
attendees: [
{
email: 'my-email-address@gmail.com',
name: 'Shashank Kumar',
status: 'NEEDS-ACTION',
rsvp: true,
type: 'INDIVIDUAL',
role: 'REQ-PARTICIPANT'
},
{
email: 'mno@gmail.com',
name: 'Mike Jack',
status: 'NEEDS-ACTION',
type: 'INDIVIDUAL',
role: 'REQ-PARTICIPANT'
},
{
email: 'xyz@gmail.com',
name: 'Will Paul',
status: 'NEEDS-ACTION',
type: 'INDIVIDUAL',
role: 'REQ-PARTICIPANT'
}
]
}
]
}).toString();
and then I'm using Nodmailer to send icalEvent
message: {
to: toEmail,
headers: {
'x-invite': {
prepared: true,
value: id
}
},
icalEvent: {
filename: 'invite.ics',
method: 'PUBLISH',
content: content
}
},