none
Adding multiple events to a single ics Calendar file RRS feed

  • Question

  • I'm facing a weird problem here. Whenever I generate an ics file with a single event and open it, the event automatically integrates nto my outlook calendar. That's very fine. However, when i add more than 1 event to a single ics file, and when i open it, it creates a new calendar in Outlook, doesn't integrate into my default outlook calendar. Please help me with this issue.....

    Thursday, February 2, 2012 9:28 AM

All replies

  • show code how you create ics with multiple events
    Thursday, February 2, 2012 11:12 AM
  • protected

     

    void btnDownloadAll_Click(GridViewRow

    row)

    {

     

    try

    {

     

    int

    i = row.RowIndex;

     

    string organizer = "sample@shedule.com"

    ;

     

    string

    location = ddlCity.SelectedValue;

     

    DataSet ds = new DataSet

    ();

     

    if

    (ddlSelect.SelectedIndex == 0)

    {

    ds = Dataobj.Get_Annual_Schedule(ddlCity.SelectedValue, ddlMonth.SelectedIndex, ddlYear.SelectedValue);

     

    if

    (ds.Tables[0].Rows.Count > 0)

    {

     

    int

    uniqKey = 0;

     

    string[] startTime = new string

    [20];

     

    string[] endTime = new string

    [20];

     

    string[] startDate = new string

    [20];

     

    string[] endDate = new string

    [20];

     

    DateTime

    sd, ed;

     

    int

    j = i + 1;

     

    if

    (i < ds.Tables[0].Rows.Count)

    {

    content.Add(

    "\nBEGIN:VEVENT"

    );

    content.Add(

    "\nORGANIZER:MAILTO:"

    + organizer);

    sd = (

    DateTime)ds.Tables[0].Rows[i]["StartDate"

    ];

    ed = (

    DateTime)ds.Tables[0].Rows[i]["EndDate"

    ];

     

    string[] stime = startTime[i].Split(':'

    );

     

    string[] etime = endTime[i].Split(':'

    );

     

    TimeSpan starttime = new TimeSpan(Convert.ToInt32(stime[0]), Convert

    .ToInt32(stime[1]), 0);

    sd = sd.Date + starttime;

     

    TimeSpan endtime = new TimeSpan(Convert.ToInt32(etime[0]), Convert

    .ToInt32(etime[1]), 0);

    ed = ed.Date + endtime;

     

    string

    test1 = sd.ToUniversalTime().ToString(DateFormat);

     

    string

    test2 = ed.ToUniversalTime().ToString(DateFormat);

    content.Add(

    "\nX-MICROSOFT-CDO-BUSYSTATUS:FREE"

    );

    content.Add(

    "\nDTSTART:"

    + sd.ToUniversalTime().ToString(DateFormat));

    content.Add(

    "\nDTEND:"

    + ed.ToUniversalTime().ToString(DateFormat));

    content.Add(

    "\nLOCATION:" + ds.Tables[0].Rows[i]["City"

    ].ToString());

    content.Add(

    "\nUID:" + DateTime.Now.ToUniversalTime().ToString(DateFormat) + "@cognizant.com"

    + uniqKey);

    content.Add(

    "\nDTSTAMP:" + DateTime

    .Now.ToUniversalTime().ToString(DateFormat));

    content.Add(

    "\nSUMMARY:" + "Annual Maintenance - " + ddlCity.SelectedValue + "-"

    );

    content.Add(

    "\nDESCRIPTION: Annual Maintenance Downtime"

    );

    content.Add(

    "\nPRIORITY:1"

    );

    content.Add(

    "\nCLASS:PUBLIC"

    );

    content.Add(

    "\nBEGIN:VALARM"

    );

    content.Add(

    "\nACTION:DISPLAY"

    );

    content.Add(

    "\nTRIGGER:-P7DT0H0M0S"

    );

    content.Add(

    "\nSUMMARY:Alarm notification"

    );

    content.Add(

    "\nEND:VALARM"

    );

    content.Add(

    "\nEND:VEVENT"

    );

    uniqKey++;

    }

    }

    }

    }

    content.Add(

     

    "BEGIN:VCALENDAR"

    );

    content.Add(

     

    "\nVERSION:2.0"

    );

    content.Add(

     

    "\nMETHOD:PUBLISH"

    );

     

     

    foreach (GridViewRow row in

    gvAnnualMaintanence.Rows)

    {

     

     

    CheckBox checkbox = (CheckBox)row.FindControl("chkGrdAnnual"

    );

     

     

    if

    (checkbox.Checked)

    {

    btnDownloadAll_Click(row);

    }

    } 

    content.Add(

     

    "\nEND:VCALENDAR"

    );

    Friday, February 3, 2012 9:51 AM
  • Code seems to be all right, more or less. I also tried to import multi event ics and outlook only cares for first event declared, so maybe it is a shortcomming of current outlook. Try to work around this by generating multiple ics files, one per each event and attach them to mail. Will this work for you?
    Friday, February 3, 2012 10:27 AM
  • Hi Damian, " I also tried to import multi event ics and outlook only cares for first event declared" - Outlook does care for the rest of the events also, but the problem is it creates a new calender when an ics file with multiple events is opened. "Try to work around this by generating multiple ics files, one per each event and attach them to mail. Will this work for you?" - Unfortunately, i'm generating a gridview with 50+ rows, each of which should be created as events in an ics file. So multiple ics files will not work for me. Any other possible solutions???

     

    Friday, February 3, 2012 11:26 AM
  • I am experiencing the same problem.  No one ever responded to DaminD's reply.  When a well-formed multi-event ics is opened by Outlook, it creates a new calendar and inserts the events into the new calendar.

    Why is it creating a new calendar?

    How do you get it to import the events in the user's primary calendar?

    Creating 50 separate ics files is not a solution; that would require the user to click on 50 files to create all the calendar entries.


    Tom Kaplan

    Wednesday, February 18, 2015 9:30 PM
  • I finally found the workaround for this.  You just drag the .ics file from the email and drop it onto your calendar icon in Outlook.  It then will not create a new calendar, all events go into your current calendar

    

    Thursday, January 18, 2018 10:37 AM