We're building a set of linked pages inside of ExactTarget using AMPscript and data extensions. The Data extensions contain events with date tags and we'd like to use these to have an ICS link appear next to each event listing. Generally what I've seen for ICS appears to involve exporting from the preferred calendar application and then uploading that and making a link to it. Anyone know of a method to automatically create one linked to an dated event from a list without needing to export, upload and link to a file.

Current Update 5/20/14 The javascript solution below supplied by Kelly is largely working and the direction we've chosen to take this. Running into a challenge based on supplying the date in the format required within the .ics (vcalendar2.0) standard. Start and end times are provided in a single, uninterrupted string (ie. "20140527T103000") Trying to use FormatDate() and it gets SO close, but still fails.

If we use this:

SET @icsStart = FormatDate(@StartDate, "YYYYMMDDTHHMM00")

AMPscript confuses the MM (as in HHMM) for Months. The months apparently need to be in a separate set of quote marks. But when we use this:

SET @icsStart = FormatDate(@StartDate, "YYYYMMDDT","HHMM00")

AMPscript adds a space where the comma is (that didn't work either - sigh) I was looking for help then thought, "One more thing to try" which was using DatePart() to grab the minutes from the date. Then use Concat() to splice together:

icsStartDate = FormatDate(@startDate, "YYYYMMDD") with icsStartMin = DatePart(@StartDate, "MI") and then use concat to create @icsStart = concat(@icsStartDate, @icsStartMin, 00). Seems to be working. Will confirm upon further testing.

The Javascript and AMPscript solution worked and events now pull information from our data extension to create the ICS files on-the-fly.

Some important details:

  • Line breaks are critical to the ics working, these must be addressed within the pages divs for the event.
  • Had to use the TZID of UTC to get times to appear in local times when we indicated to people adding items to the DE to use UTC time when they add item date/times.
  • Could you overcome the format date with multiple lines and then using concat in the end? (so you generate variables for date, month, year etc. - and then store them in individual variables used in a concat function at the end, instead of formatdate? – Kenneth Wagner Jul 6 '17 at 6:57

It looks like there is a SO question that addresses this:

Create .ics file on the fly using javascript or jquery?

Fiddle sample

| improve this answer | |
  • I'm sure in time I will learn to better search on SO and find some of my own answers, meanwhile, thanks - going to review that now! – Jonny Shaw Dec 12 '13 at 21:19
  • Did this end up working for you? – Kelly J Andrews Jan 3 '14 at 15:09
  • I haven't placed it yet (didn't want you thinking I was unappreciative or unresponsive) My task list moved into other directions so this will still be useful but for now I'm focused on other priorities. The workaround is that we will manually upload an ics to a portfolio area and manually link to it. I did inspect the fiddle and it looks fairly straightforward so I hope my attention goes there soon and that it overall works as expected. – Jonny Shaw Jan 16 '14 at 14:25
  • Was looking at that and while it does appear to "sorta" work, I was looking for and can't find a spot to edit the event date/time. Was fiddlin' around with it but to no avail. Am now also looking at ics.js to see if that is the ticket here. – Jonny Shaw May 14 '14 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.