Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MK 429 posts 906 karma points
    Jun 07, 2012 @ 13:30
    MK
    0

    creating .ics files

    Hi there,

    I would like to creat an .ics file when creating my custom event node.

    Is there  plug in for this or an easy way of doing it?

    cheers

    mkariti 

  • Connie DeCinko 931 posts 1160 karma points
    Feb 26, 2014 @ 17:30
    Connie DeCinko
    0

    Did you find a solution?

     

  • MK 429 posts 906 karma points
    Feb 26, 2014 @ 18:25
    MK
    0

    Yes. was quite easy actually. 

     

                    DateTime created = DateTime.Now;

                    DateTime start = DateTime.Parse(node.GetProperty("startTime").Value);

                    DateTime end = DateTime.Parse(node.GetProperty("endTime").Value);

                    DateTime lastModified = DateTime.Now;

                    string subject = ("" + node.Name).Replace("\n", "");

                    string body = ("" + node.Name).Replace("\n", "");

                    string addZ = string.Empty;

        

                        TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);

                        start = TimeZoneInfo.ConvertTimeToUtc(start, timeZoneInfo);

                        end = TimeZoneInfo.ConvertTimeToUtc(end, timeZoneInfo);

                        addZ = "z";

             

                    string location = (node.GetProperty("location").Value).Replace("\n", "");

                    context.Response.AddHeader("content-disposition", "attachment;filename=" + node.Name + ".ics");


                    context.Response.Write("BEGIN:VCALENDAR" + Environment.NewLine);

                    context.Response.Write("VERSION:2.0" + Environment.NewLine);

                    context.Response.Write("PRODID:-//www.xxx.com" + Environment.NewLine);

                    context.Response.Write("METHOD:PUBLISH" + Environment.NewLine);

                    context.Response.Write("BEGIN:VTIMEZONE" + Environment.NewLine);

                    context.Response.Write(@"TZID:(GMT) Greenwich Mean Time ." + timeZone + @"\" + Environment.NewLine);

                    context.Response.Write("TZOFFSETFROM:+0000" + Environment.NewLine);

                    context.Response.Write("TZOFFSETTO:+0000" + Environment.NewLine);

                    context.Response.Write("END:VTIMEZONE" + Environment.NewLine);

                    context.Response.Write("BEGIN:VEVENT" + Environment.NewLine);

                    context.Response.Write("SUMMARY:" + subject + Environment.NewLine);

                    context.Response.Write("LOCATION:" + location + Environment.NewLine);

                    context.Response.Write("DTSTART:" + start.ToString("yyyyMMddTHHmm") + "00" + addZ + Environment.NewLine);

                    context.Response.Write("DTEND:" + end.ToString("yyyyMMddTHHmm") + "00" + addZ + Environment.NewLine);

                    context.Response.Write("CLASS:PUBLIC" + Environment.NewLine);

                    context.Response.Write("END:VEVENT" + Environment.NewLine);

                    context.Response.Write("END:VCALENDAR");

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies