2

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.
1
  • 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? Commented Jul 6, 2017 at 6:57

2 Answers 2

2

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

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

Fiddle sample

4
  • 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
    Commented Dec 12, 2013 at 21:19
  • Did this end up working for you? Commented Jan 3, 2014 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
    Commented Jan 16, 2014 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
    Commented May 14, 2014 at 18:43
0

The issue is the date "20140527T103000". For the DateFormat to work the date needs to be 2014-05-27-T-10-3000. So, you need to do a multi-step process of using a Substring function. Substring("20140527T103000",1,4) and you will get 2014. Do this multiple times and pass each substring into a variable. Next step is to Concat the variables and add a dash between each variable.

Set @year = Substring("20140527T103000",1,4) Set @month = Substring("20140527T103000",5,2) Set @day = Substring("20140527T103000",7,2)

SET @date = Concat(@year, "-",@month, "-",@day)

set @monthFullName = FormatDate(@date,"MMMM")

SET @Subjectline = Concat("Here's a copy of your ", @monthFullName, " bill")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .