Create Ical item from data to send by email

Related products: Windows GUI

We have a wish to send an ical (calender item) file to an extern email address. If we can create an ical file we can easily invite people to appointments without switching to outlook.

The ical format is pretty standardized and the most used calenders can work with this.
Hey Edwin,

That's a great idea, I actually created my own code to write an iCal file and send it through dbmail. But it would have been much easier if there would have been a connector which could handle this.
Hi Pim, Are you willing to share your code?
Not sure whether I'm allowed, I will run that by my superiors. But I may be able to point you in the right direction.



First of all, here is an example of how to create a string containing an ical file: https://sqlqueen.wordpress.com/2011/04/25/create-ics-file-in-sql-server/



Where I use this, an e-mail is sent right after the ical file is created. Now dbmail is not able to send actual files, but it is able to send query results. So the way I do it is as follows:


  1. I query all my necessary parameters
  2. I create a string which I fill with the parameters.
  3. I build a query in text 'set nocount on; select ''@icalString'' '. Note the 'set nocount on' this is necessary, because otherwise the output will contain 'x number of rows affected'
  4. I call sp_send_dbmail with the necessary parameters and the built string as query, note following fields in particular

  • @query = [the query you built]
  • , @attach_query_result_as_file = 1
  • , @query_attachment_filename = [yourfilename].ics
  • , @query_result_header = 1 --not sure why anymore
  • , @query_no_truncate = 1

I hope this is enough for you to get this working. Now the same would work if you wanted to send an a-mail through a process, but then it would not be necessary to build the string as a query
Another route is to use the Thinkwise Exchange 365 connector-in and insert meetings with a title, body and recipient - that will in turn show up as a regular meeting invite in that person's mailbox. In this case Outlook itself also doesn't have to be opened because it will all happen server side.



More on this https://office.thinkwisesoftware.com/docs/docs/kb/exchange.html

Unfortunately, this idea has not received enough votes. Because we want to keep the focus on ideas that are in high demand in our Community, we are closing this idea.

Fortunately, as @Mark van den Berg pointed out an alternative for this is present.

Updated idea status OpenClosed