Reputation: 855
I am trying to send calendar invite using node js.
I have tried nodemailer library and is sending mail with calendar invite
Like in reference to this question
but this is sending invite like
suggest some help if anyone knows better approach.
[update]
using google-calendar api
the output is showing like
Upvotes: 7
Views: 8517
Reputation: 449
sendNotifications is deprecated, use sendUpdates. Notice it isn't boolean but string.
calendar.events.insert({
auth: auth,
calendarId: 'primary',
resource: event,
sendUpdates: 'all',
}, function(err, event) {
if (err) {
console.log('There was an error contacting the Calendar service: ' + err);
return;
}
console.log('Event created: %s', event.htmlLink);
});
From typescript signatures:
* @param {boolean=} params.sendNotifications Deprecated. Please use sendUpdates instead. Whether to send notifications about the creation of the new event. Note that some emails might still be sent even if you set the value to false. The default is false.
* @param {string=} params.sendUpdates Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
Upvotes: 2
Reputation: 681
If someone is still looking for an answer :
Try updating your events.insert payload with sendNotifications key as shown
var calendar = google.calendar("v3");
calendar.events.insert({
auth: auth,
calendarId: "primary",
resource: event,
sendNotifications:true
}, function(err, event) {
if (err) {
console.log("There was an error contacting the Calendar service: " + err);
return;
}
console.log("Event created: %s", event);
});
This will send an email to all the attendees sent as part of event meta data as directed in google docs
Upvotes: 0
Reputation: 5097
I would use the Google Calendar API: https://developers.google.com/google-apps/calendar/create-events, you can do this using a library such as https://www.npmjs.com/package/google-calendar. It also has the benefit that you won't have to send emails from your server.
In this way you can add attendees and the invite will be the same as if you sent the request directly from the calendar instead of Google interpreting your email as a calendar event.
The event you create appears on all the primary Google Calendars of the attendees you included with the same event ID. If you set sendNotifications to true on your insert request, the attendees will also receive an email notification for your event. See the events with multiple attendees guide for more information.
Upvotes: 2