简体   繁体   中英

How do I send users a calendar invite?

Users book appointments on my website. I want to send them a google calendar invite so that they can accept and have it in their calendar. How can I do that with node is and sendgrid?

Gmail automatically parses attached .ics files and suggests the users in the UI to add them to their calendars. This means you need to build the right ics attachment and use the following snippet to attach it to the email you are sending:

const SendGrid = require("@sendgrid/mail");

  const attachment = {
    filename: 'invite.ics',
    name: 'invite.ics',
    content: Buffer.from(data).toString('base64'),
    disposition: 'attachment',
    contentId: uuid(),
    type: 'text/calendar; method=REQUEST',
  };

    await SendGrid.send({
      attachments: [attachment],
      templateId,
      from: {
        email: config.emailSender,
        name: config.emailName,
      },
      to: user.email,
      dynamicTemplateData: templateData
   });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM