I am sending emails with Nodemailer, furthermore I use the ical-generator package to generate .ics files, these files are visible as an attachment in the email I sent, but there is no button which display an instant action to accept the invitations like some other mails show.
This is my current implementation:
export default function generateIcal(req, res) {
const generatedEvents = req.body.data.map(d => ({
start: new Date(d.date),
end: new Date(addDays(d.date, 1)),
summary: req.body.summary,
organizer: {
name: 'Frodo',
email: 'frodo@cool.com',
mailto: 'jonwick@gmail.com'
},
}))
try {
const data = ical({
method: "REQUEST",
domain: "https://mydomain.de",
name: 'test',
events: generatedEvents
}).toString();
return res.status(200).json({ data })
} catch (error) {
return res.status(error.statusCode || 500).json({ error: error.message });
}
}
This is how I use Nodemailer in that case:
try {
let info = await transporter.sendMail({
sendMail: true,
from: sender, // sender address
to: req.body.email, // list of receivers
subject: `test.`,
text: 'test',
icalEvent: {
filename: 'invite.ics',
method: 'request',
content: calContent // content generated above
},
```