Calendar invitations are some of the most used features by everyone, especially now that we’re all doing remote meetings and having a lot of them. These calendar events are usually ICS calendar event files that are attached to your email and that your email provider knows how to interpret and adds 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 BEGIN:VEVENT URL: DTSTART: DTEND: SUMMARY: DESCRIPTION: LOCATION: 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 that has a lot more detail, but starting, let’s keep it simple.
BEGIN:VCALENDAR VERSION: 2.0 BEGIN:VEVENT
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). Consider this as the start of the definition of the event.
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 has to 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. The 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 if you press enter on the text it won’t translate into a new line in the description. 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, so make it something user-friendly.
Get the file contents:
We do this because, above, we don’t have a file, but only a string of text. To be able to send a file attached in the email, we need to create it, and that’s what’s happening here. 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. If you don’t know, I have a template area where I publish stuff that you can import and use without having to put all together. 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.
Edit on 24th, August 2002: Big thanks to Rob from the Power Automate Community catching a big mistake in this article.