locked
Columns Needed To Create ICAL or Outlook Calender Events RRS feed

  • Question

  • User955702898 posted

    Hi All,

    I am just looking for the general columns needed to create an ICal or Outlook Event so that when I input the data into a database it can be translated into an iCal or Outlook Even. Specifically I am looking for Information like Start Date, End Date, Start Time, End Time, Recurrence.


    Saturday, March 13, 2010 6:29 PM

Answers

  • User-525215917 posted

    This is code example from my blog (yes, it is for SharePoint but you get the idea):

    protected void downloadButton_Click(object sender, EventArgs e)
    {
        SPListItem item = SPContext.Current.ListItem;
     
        try
        {
            string location = item["Location"] as string;
            string subject = item.Title;
            string description = item["Description"] as string;
     
            var beginDate = (DateTime)item["From"];
            var beginDateString = beginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");
     
            var endDate = (DateTime)item["Thru"];
            var endDateString = endDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");               
     
            string[] contents = {
                          "BEGIN:VCALENDAR",
                          "PRODID:-//My company//My product//EN",
                          "BEGIN:VEVENT",
                          "DTSTART:" + beginDateString,
                          "DTEND:" + endDateString,
                          "LOCATION:" + location,
                          "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + description,
                          "SUMMARY:" + subject, "PRIORITY:3",
                          "END:VEVENT",
                          "END:VCALENDAR" };
     
            HttpResponse response = HttpContext.Current.Response;
     
            response.Clear();
            response.ContentType = "text/calendar";
            response.AddHeader("Content-disposition", "attachment;filename=event.ics");
            response.Write(string.Join("\r\n", contents));
            response.Flush();
            response.End();
        }
        catch (System.Threading.ThreadAbortException taex)
        {
            // Ignore this exception
        }
    }


    This code is tested on Outlook 2003 and Outlook 2007.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 14, 2010 4:36 AM

All replies

  • User197322208 posted

    http://en.wikipedia.org/wiki/ICalendar

    Saturday, March 13, 2010 7:25 PM
  • User-525215917 posted

    This is code example from my blog (yes, it is for SharePoint but you get the idea):

    protected void downloadButton_Click(object sender, EventArgs e)
    {
        SPListItem item = SPContext.Current.ListItem;
     
        try
        {
            string location = item["Location"] as string;
            string subject = item.Title;
            string description = item["Description"] as string;
     
            var beginDate = (DateTime)item["From"];
            var beginDateString = beginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");
     
            var endDate = (DateTime)item["Thru"];
            var endDateString = endDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");               
     
            string[] contents = {
                          "BEGIN:VCALENDAR",
                          "PRODID:-//My company//My product//EN",
                          "BEGIN:VEVENT",
                          "DTSTART:" + beginDateString,
                          "DTEND:" + endDateString,
                          "LOCATION:" + location,
                          "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + description,
                          "SUMMARY:" + subject, "PRIORITY:3",
                          "END:VEVENT",
                          "END:VCALENDAR" };
     
            HttpResponse response = HttpContext.Current.Response;
     
            response.Clear();
            response.ContentType = "text/calendar";
            response.AddHeader("Content-disposition", "attachment;filename=event.ics");
            response.Write(string.Join("\r\n", contents));
            response.Flush();
            response.End();
        }
        catch (System.Threading.ThreadAbortException taex)
        {
            // Ignore this exception
        }
    }


    This code is tested on Outlook 2003 and Outlook 2007.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 14, 2010 4:36 AM