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.