2

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');?

gmail image

outlook image

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

Narendra M
  • 21
  • 5
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 02 '22 at 16:28
  • Look at existing emails sent from others / other programs, that display as you expect. Then look at the source for those emails. Compare to the source of yours. Fix the differences. Sorry, without you posing a [mcve] it's impossible to tell what is missing. – Robert Jun 02 '22 at 16:30

1 Answers1

1

I suspect partstat: 'ACCEPTED' for attendee could be a culprit here, consider changing it to 'NEEDS-ACTION'.

I recommend checking out this answer which doesn't use ical-generator. Export the raw iCal file and compare the output.

jnv
  • 882
  • 10
  • 18
  • 1
    Thanks for the answer, But as google events are having lot of features, I have achived complete thing through google calendar events. [link]https://developers.google.com/calendar/api/v3/reference/events/insert – Narendra M Jun 10 '22 at 08:53