How can I set up a calendar invite for outlook when registering for an event via a form

Is it possible to email someone a calendar invite that they can add to their Outlook calendar?

1 Like

Hi Mel,

Assuming you have a form with the following fields setup:

Obviously, you can add other fields but these fields are the minimum required to generate a calendar invite.

In the screen JS you need to add the following code:

Fliplet.Hooks.on('afterFormSubmit', function(response) {
  //Format the start time for the calendar event
  var startTimeStamp = (
    moment(response.formData['Date']).format('YYYYMMDD') +
    'T' +
    response.formData['Start time'] +
  ).replace(/:/gi, '');
  //Format the end time for the calendar event
  var endTimeStamp = (
    moment(response.formData['Date']).format('YYYYMMDD') +
    'T' +
    response.formData['End time'] +
  ).replace(/:/gi, '');
	//Add location of the event to calendar invite
  var location = response.formData['Location'];
  //Email subject will be the event name
  var subject = response.formData['Event name'];
//Create the calendar invite
  var test =
PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN
    startTimeStamp +
    endTimeStamp +
    location +
    subject +

  //Send an email to the email mentioned in the "Email" form field. 
  var options = {
    to: [{ email: response.formData.Email, type: 'to' }],
    html: 'Please save the attached calendar notice for the event',
    subject: subject,
    attachments: [
        type: 'text/calendar;charset=utf-8',
        name: 'event.ics',
        content: btoa(test)
  return Fliplet.Communicate.sendEmail(options);

This code snippet will format the data from the form and send an email to the user with a calendar invite attached. Note: Once the user receives the email they will have to import the invite into the calendar, it is not automatically added.

Hope this helps,

1 Like

Thanks Deb for providing some great insight and a solution our bespoke request. Also for Mel for orchestrating this on my behalf!

I have followed your instructions, and I have an error where it says Missing required Header ‘To’. I wonder if this is because I’m using the wrong email address header.

I have matched the fields you have mentioned and only added a checkbox at the option.

Any ideas on how to get around this?


Hi Jonathan,

Can you confirm if you have a form field called “Email” in your form?

Thanks Deb,

That seems to work! When creating the form , there was a default field which had email so I left it. I deleted that field, and added the email text box which did the trick!

Many thanks for this. Let me check with my team.

Best wishes


1 Like