I am using mailgun(node js) to send an calendar invite, I am able to send invites but it is not adding to calendar automatically.
How we can automate this calendar invite to gmail, outlook calendar?
How can i achieve Yes, Maybe, No or RSVP or accept or reject options for both gmail and outlook using mailgun(node js) using ical-generator, Ex: var ical = require('ical-generator');?
Hi Robert, Thanks for the your time and suggestion.
I have tried using the similar .ics file which gamil gives but it really didn't work to auto sync to calendar or "Yes", "No", "May be" options.
Here is the other example what i have written and trying auto calendar sync and "Yes", "MayBe", "No"options.
Using node module 'ical-generator'.
var ical = require('ical-generator');
var eventObj = {
'start' : '2022-06-02T06:59:52.653Z',
'end' : '2022-06-02T07:59:52.653Z',
'title': "Test mail",
'subject': 'Hey There, Im testing API',
'description': 'Hi User',
"Content-Type": "text/calendar,method=REQUEST",
"method": "REQUEST",
'url': "<domain>",
'id' : '125756xr378',
'organiser' : {'name' : 'Narendra M', 'email':'narendrahd@example.in'},
'location' : 'USA, main',
organizer: { name: 'Narendra M', email: 'narendrahd@example.in' },
attendees: [
{ name: 'Narendra M', email: 'narendrahd@example.in', rsvp: true, partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT' },
],
};
var cal = ical();
Creation of an event using ical.
cal.createEvent({
start: eventObj.start,
end: eventObj.end,
summary: eventObj.title,
method: eventObj.method,
uid: eventObj.id, // Some unique identifier
sequence: 0,
subject: eventObj.subject,
description: eventObj.description,
'Content-Type': "text/calendar,method=REQUEST",
location: eventObj.location,
organizer: {
name: eventObj.organiser.name,
email: eventObj.organiser.email
},
attendees: [
{ name: 'Narendra M', email: 'narendrahd@example.in', rsvp: true, partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT' },
],
});
var path = __dirname + eventObj.id + '.ics';
cal.saveSync(path);
craetion of request and rest call to run mailgun API
var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.mailgun.net/v3/<domain>/messages',
'headers': {
'Authorization': 'Basic <token>'
},
formData: {
'from': 'noreply@dummy.in',
'to': ['narendrahd@example.in', 'iamnotveda@example.com'],
'subject': 'Hey There, Im testing API',
'text': 'Hi User',
// 'html': '\'<html><body><p>Hi User,</p></body></html>\'',
'attachment': [{
//'value': fs.createReadStream('/Users/invite.ics'),
'value': fs.createReadStream(path),
'options': {
'filename': 'invite.ics',
'contentType': "application/ics,method=REQUEST"
}
},
]
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Thanks in advance. Narendra