Calendar invitations are some of the most used features by everyone, especially now that we’re all doing remote meetings and having many of them. These calendar events are usually ICS calendar event files attached to your email, and that your email provider knows how to interpret and add to your calendar. Also, you never have to generate them because your email client takes care of that for you.
But were you aware that you can quickly build and send one using Power Automate if you need to send an invitation to someone? It’s quite simple, so let me show you how to do it.
An ICS calendar event is a text file with a defined structure. Once you know it, it’s easy to build one, and, thankfully, the whole process is quite simple. Here’s an example:
BEGIN:VCALENDAR VERSION:2.0 PRODID:-//ManuelTGomes.com//NONSGML ICS Demo//EN BEGIN:VEVENT UID: DTSTAMP: DTSTART: DTEND: SUMMARY: DESCRIPTION: LOCATION: URL: END:VEVENT END:VCALENDAR
It’s quite self-explanatory, but let’s go through the items and check the structure of each one of the above. If you want to go deeper, I recommend checking Wikipedia’s entry on this with a lot more detail, but let’s keep it simple.
BEGIN:VCALENDAR VERSION: 2.0 BEGIN:VEVENT
The PRODID can be static but needs to be defined. In my case, I’ve defined my website, but you can provide any string that makes sense to you.
PRODID:-//ManuelTGomes.com//NONSGML ICS Demo//EN
The application starts reading the file and knows that this is a Calendar (VCALENDAR) file with version 2 (V2.0) of the structure, and it has an even (VEVENT). So consider this as the start of the definition of the event.
Some platforms require that the calendar event has a unique identifier. In our case, we’re generating one based on the date so that we can ensure that there’s uniqueness.
The timestamp that the calendar event is being generated. It should not be the same as the start or end of the event, but the instant we generate the ICS file.
Some events have URLs for stuff like meeting rooms, websites, and more, so here’s where you put the URL that you want your calendar to point to. You can add this to the description also.
The “DTSTART” has the start date of the event. Note that the date format must be in the ISO 8601 (catchy name, right?!?! 😀) above. YYYYMMDDThhmmssZ, so I the example:
- YYYY – The full-year 2020
- MM – Month 12 with always two characters.
- DD. Day 24 with always two characters.
- T signals the time comes after
- hh – The hour in 24-hour format and always with two characters.
- mm – The minute with always two characters
- ss – The seconds with always two characters
- Z – indicates that is the UTC (0h offset)
The same above but for the end date of the event.
Usually, the summary will be the title of the event in your calendar entry.
This field represents the description or body of the calendar’s entry. Note that you don’t need to use double quotes or quotes in this field. You can add the text freely, but be aware of the carriage returns. It means that it won’t translate into a new line in the description if you press enter on the text. So you should include instead n if you want to do that.
The location of the event in a text format. Some applications can translate this into addresses and other things, but the basis is always a text entry.
END:VEVENT END: VCALENDAR
When the app reads this part, it knows it’s reading the end of the file.
How to do it in Power Automate
After seeing the structure, you can understand how easy it will be to generate the file. For that, you need only to create a text entry with this, save a file with the .ics, and send it. Here’s the full Power Automate, and then we can go step by step.
The trigger is simple to get all the information that we need:
You can easily see that these are the fields that we need for our example file above.
Now let’s form the ICS file:
Super easy, right? The only caveat is that we need to be careful to convert the date to the format:
Easy also. We get the date from the trigger and define the ISO format that we need.
Now let’s generate the ICS calendar event:
The directory is not essential. We’ll delete the file later. The name is also not crucial, but it’s the one that the user will see, making it user-friendly.
Get the file contents:
We do this because, above, we don’t have a file but only a text string. So, to send a file attached in the email, we need to create it, and that’s what’s happening here. Then, you can fetch it using the ID from the previous step.
We can send an email as simple as this:
And finally, let’s delete the file:
As you can see, it’s not hard, and it’s beneficial to generate these invitations dynamically. I have a template area where I publish stuff that you can import and use without putting it all together if you don’t know. So take a look and let me know if there’s one that you would like to be featured there.
Disclaimer: This article was inspired by a question that I answered on the Microsoft Power Automate Community.