Click here to Skip to main content
Click here to Skip to main content

Adding iCalendar Support to Your Program - Part 1

By , 14 Apr 2010
 
Screenshot - iCalendar_Part1.jpg

Introduction

This article describes how to load and view iCalendars by using the DDay.iCal library. I will cover more advanced topics, such as creating, editing, and serializing iCalendars in my next article.

In this article, I will walk you through creating a console application that will load and display upcoming events to the user. I've also included an example project that demonstrates how to add this kind of support to an ASP.NET web application.

Background

Many programmers have worked with adding some kind of calendar support to an application - from displaying upcoming events on a web site, to allowing personalized calendars, with the ability to alter them.

So, thousands of programmers, all adding calendar support to their applications. So, what's the problem with that? The historical answer is that no (or very few) programmers followed any kind of standard to implement their calendars. So, if you needed to accomplish anything else with the calendar that your original application didn't support, you'd have to write it by hand.

Also, these ad-hoc calendars are only viewable from the application that wrote them. What if you want to allow for recurrences in your calendar, so an event can recur "every 2nd-to-last Sunday of the month?" What if you want to publish your calendar, so others can subscribe to it, and view it from the calendar program they prefer? What if you want to display and manipulate calendars from multiple sources, including sources that you may not have control over?

These are some of the problems the iCalendar standard solves for us. If you didn't already know -- iCalendar is a W3C recommendation known as RFC 5545. You can find it here.

Using the Code

To begin, open Visual Studio and create a "Windows Console Application" project. Then, if you haven't already done so, download the latest binary version of DDay.iCal from SourceForge.net. Once you've done that, you simply need to add a reference to DDay.iCal.dll from your project (i.e. click "Add Reference" from the "Project" menu).

Then, add the following to the top of the Program.cs file:

using DDay.iCal;

You're now ready to load your first iCalendar! There are multiple ways you can load iCalendars, ranging from simply loading the file from your local filesystem, to loading from a WebDAV or CalDAV store, to loading from a database. The possibilities are endless; however, in this article, we'll focus on simply loading the file from your local filesystem. Add the following code to your Main() method (of course, replacing the path with the actual path to your iCalendar file).

// Load the calendar file
IICalendarCollection calendars = iCalendar.LoadFromFile(@"path\to\your\icalendar.ics");

Congratulations, you've loaded your iCalendar, and are ready to work with it! For now, let's display the events that occur today:

//
// Get all events that occur today.
//
IList&occurrence> occurrences = calendars.GetOccurrences
	(DateTime.Today, DateTime.Today.AddDays(1));

Console.WriteLine("Today's Events:");

// Iterate through each occurrence and display information about it
foreach (Occurrence occurrence in occurrences)
{
    DateTime occurrenceTime = occurrence.Period.StartTime.Local;
    IRecurringComponent rc = occurrence.Source as IRecurringComponent;
    if (rc != null)
        Console.WriteLine(rc.Summary + ": " + occurrenceTime.ToShortTimeString());
}

That's it! To be clear, calendars.GetOccurrences(...) returns a list of Occurrence objects. Occurrence objects describe each occurrence, including the date/time the occurrence happens, and a reference to the original component that generated the occurrence. We cast the Source of the occurrence to an IRecurringComponent, and display its properties.

So, now we've displayed all the events that occur today. Let's display all of the upcoming events that will occur within the next 7 days:

//
// Get all occurrences for the next 7 days, starting tomorrow.
//
occurrences = calendars.GetOccurrences
		(DateTime.Today.AddDays(1), DateTime.Today.AddDays(7));

Console.WriteLine(Environment.NewLine + "Upcoming Events:");

// Start with tomorrow
foreach (Occurrence occurrence in occurrences)
{
    DateTime occurrenceTime = occurrence.Period.StartTime.Local;
    IRecurringComponent rc = occurrence.Source as IRecurringComponent;
    if (rc != null)
        Console.WriteLine(rc.Summary + ": " + occurrenceTime.ToString());
}

As you can see, this code is nearly identical to "Today's Events", with a slight difference at calendars.GetOccurrences(...). We also display the full date/time of the recurrence this time.

Note: If you're only interested in certain kinds of components (i.e. Events, Todos, etc.), then you can get occurrences for only those events using the generic version of GetOccurrences (i.e. calendars.GetOccurrences<IEvent>(...)).

Final Code

Here's the final result of Program.cs:

using System;
using System.Collections.Generic;
using System.Text;

// Required DDay.iCal namespace
using DDay.iCal;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the calendar file
            IICalendarCollection calendars = iCalendar.LoadFromFile(@"Business.ics");

            //
            // Get all events that occur today.
            //
            IList&occurrence> occurrences = calendars.GetOccurrences
				(DateTime.Today, DateTime.Today.AddDays(1));

            Console.WriteLine("Today's Events:");

            // Iterate through each occurrence and display information about it
            foreach (Occurrence occurrence in occurrences)
            {
                DateTime occurrenceTime = occurrence.Period.StartTime.Local;
                IRecurringComponent rc = occurrence.Source as IRecurringComponent;
                if (rc != null)
                    Console.WriteLine(rc.Summary + ": " + 
				occurrenceTime.ToShortTimeString());
            }

            //
            // Get all occurrences for the next 7 days, starting tomorrow.
            //
            occurrences = calendars.GetOccurrences
		(DateTime.Today.AddDays(1), DateTime.Today.AddDays(7));

            Console.WriteLine(Environment.NewLine + "Upcoming Events:");

            // Start with tomorrow
            foreach (Occurrence occurrence in occurrences)
            {
                DateTime occurrenceTime = occurrence.Period.StartTime.Local;
                IRecurringComponent rc = occurrence.Source as IRecurringComponent;
                if (rc != null)
                    Console.WriteLine(rc.Summary + ": " + occurrenceTime.ToString());
            }
        }
    }
}

Points of Interest

For more information, visit the DDay.iCal homepage at ddaysoftware.com.

Many apologies that it's taken so long to update this article. I'll now be providing more frequent updates.

History

  • 04/14/2010 - Updated to version 1.0 Alpha
  • 03/09/2007 - Posted

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

Douglas Day
Web Developer
United States United States
Doug has been a Software Engineer for 7 of the previous 9 years, and has 12 years of programming experience.
 
For the past 3 years, he has been developing custom applications in C# and Visual Basic.NET, with an emphasis on custom cross-Internet applications for IT management, real-time collaboration, and process management and reporting.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralOT [ Bad tutorial link from your home page for DDay.Update]memberGarth J Lancaster15-Apr-10 0:18 
the link goes to http://www.codeproject.com/useritems/DDayUpdate_Part1.asp[^]
 
which doesnt exist - the page looks like its been moved since to
 
Adding automatic updates to your program - Part 1[^]
 
your code/articles look great - thanks for sharing your knowledge
 
'g'
GeneralWould be nice if article could be updated for version 0.80membermanudurand14-Mar-10 1:52 
Hi Doug,
First of all, thanks a lot for this project, it's really useful. Thumbs Up | :thumbsup:
I intend to use your library to consume .ics calendars (published to web from Outlook 2007) and display the events on a Calendar control on an aspx page, all in C# code-behind.
It would be nice if you could update this article (or create a new one) with the newest version on DDay.iCal (version 0.80).
In particular, could you describe what is the Occurence object relative to the Event object? Which one should I loop through to get my list of events on each day (when my DayRenderEventHandler gets fired)?
Thanks again,
Emmanuel
GeneralRe: Would be nice if article could be updated for version 0.80memberDouglas Day14-Mar-10 10:30 
Funny you mention an updated article. I'm currently making some major changes to DDay.iCal and I'll update this article when that new version is released (likely to be version 0.90).
 
What you want to do is call Event.GetOccurrences(...) and use the list of Occurrence objects returned in your DayRenderEventHandler to show the different events.
 
Let me know if you have more questions.
 
Thanks,
-Doug
GeneralRe: Would be nice if article could be updated for version 0.80membermanudurand14-Mar-10 16:21 
Hi Doug,
Right now, I'm calling _Calendars.GetOccurrences<Event>(...) which returns me a list of Event Occurences. Then, for each day, I loop through each Occurrence object from the list. Which date should I compare with my DayRender date? occ.Period.StartTime.Local.Date or occ.Component.Start.Local.Date? Not quite sure what's the difference between these two...
Thanks again,
Emmanuel
GeneralRe: Would be nice if article could be updated for version 0.80memberDouglas Day14-Mar-10 17:01 
Use occ.Period.StartTime.Local.Date. This represents the current occurrence date/time, whereas occ.Component.Start.Local.Date represents the date/time of the original component. For example, if you schedule an event that starts on March 14th, 2010 at 8:00 AM, and recurs every week on the same day/time. evt.GetOccurrences(...) would return the following dates (contained in Occurrence.Period):
 
3/14/2010 8:00 AM
3/21/2010 8:00 AM
3/28/2010 8:00 AM
4/4/2010 8:00 AM
etc.
 
You'll notice on each of these Occurrence objects, the 'Component' points back to the original event (March 14th, 2010 at 8:00, and recurs every week).
 
Hope that clears it up a bit.
 
Let me know if you have more questions.
 
Thanks,
-Doug
GeneralRe: Would be nice if article could be updated for version 0.80membermanudurand14-Mar-10 19:50 
Got it now.
Thanks for the explanation, it's very much appreciated.
I'll keep an eye on the next version release (any expected date?).
Emmanuel
GeneralRe: Would be nice if article could be updated for version 0.80memberDouglas Day15-Mar-10 5:24 
Glad it's working Smile | :)
 
I plan on releasing the new version within the next week, two at most. It's been an almost complete rewrite of the code base to allow for better parsing, serialization, and object-model simplicity.
 
Keep on eye on SourceForge for the release. Smile | :)
 
Regards,
-Doug
GeneralRe: Would be nice if article could be updated for version 0.80memberDouglas Day15-Apr-10 6:06 
I just updated this article for the new release of DDay.iCal. Let me know what you think.
 
Thanks,
-Doug
Questiongreat articlememberjael3624-Nov-09 9:55 
thanks for this. I have been looking into something like this all day...
 
my big question is: can ics files support outlook tasks as well as outlook calendar appointments?
 
The reason i ask is that everyone is concerned about synchronizing with the outlook calendar, but not many about setting new tasks!
 
Also, can we limit this to a 1-way feed? From a custom web calendar to outlook but not the reverse? I suppose it would be a setting within the custom web calendar.
AnswerRe: great articlememberDouglas Day29-Dec-09 10:01 
Yes, iCalendar support Events as well as Todo items.
 
As far as the 1-way feed, that would be a setting in Outlook, or in the web server that distributed the iCalendar.
 
And sorry about the late response, just saw this Smile | :)
-Doug
GeneralThanksmemberMember 45575835-Aug-09 3:23 
Hi Doug,
 
Thank you for such a wonderful post. It helped me a lot.
Can you also give me an idea how to parse vcards.
 

Thanks
Panna
GeneralRe: ThanksmemberDouglas Day5-Aug-09 4:12 
Panna,
 
I'm glad you've found DDay.iCal useful - don't forget to use the most recent version (now 0.71) from SourceForge.net[^], if you haven't done so already.
 
As far as vcards go, I haven't really given it much thought. In theory, it's a very close format to iCalendar, so I could share some of the code base and create a library for it. I'll give some thought to it, and if I have the time and use for it, I'll put it together.
 
In the meantime, there are several articles on CodeProject about vcard. Just search for "vcard c#".
 
-Doug
GeneralEvent.OccursOn and events that span two UTC days but is only 2 hours longmemberi.i. wiin30-Apr-09 14:38 
I'm having difficulties getting the Event.OccursOn to work properly. I have an event that starts at the 17th at 4PM Mountain Standard Time and runs for 2 hours. This converts to 11PM UTC to 1AM UTC the next day. Event.OccursOn evals to true irregardless of which of the two days (the 17th or 18th) I pass in as a UTC date. So when iterating thru the dates (as in the console app), that same event is now listed for both days, but the date is displayed using "evt.Start.Local.ToShortTimeString()". This is very confusing because is shows a two hour event starting at 4PM the 17th and 4PM the 18th as well. It should only display for the 17th. I'm having to manually check each Start Date and End Date with my own logic to really tell if that event is for the 17th or the 18th. Or am I confused here?
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberDouglas Day30-Apr-09 14:53 
Yes, if you want to be truly accurate, you cannot convert times to UTC. You need to use time zones instead.
-Doug
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberi.i. wiin1-May-09 5:58 
Can you explain how to use TimeZones? I'm consuming someone else's iCalendar output, so I can't change it there.
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberDouglas Day1-May-09 6:03 
Unfortunately, if you're consuming someone else's iCalendar output, you cannot "fix" the accuracy of the calendar. When an event is recorded that it happened from 11:00 PM to 1:00 AM (regardless of the UTC designation), then it "occurred" on both days. This information is important to preserve, as it maintains the accuracy of the calendar.
 
So - you might need to use another method other than "OccursOn" to build your calendar.
 
Let me know if you have more questions,
-Doug
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberi.i. wiin1-May-09 6:10 
Doug, just gotta say, _THANK YOU_ for the extraordinarily quick responses to my questions! Big Grin | :-D
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberDouglas Day1-May-09 6:55 
No problemo, let me know if you have more questions.
-Doug
GeneralRe: Event.OccursOn and events that span two UTC days but is only 2 hours longmemberi.i. wiin1-May-09 6:06 
Also, does this TimeZone issue affect the way I pass in dates into the Event.Evaluate() function?
GeneralAttachment ProblemmemberMember 22397698-Dec-08 5:24 
I am having hard time attaching a Word 2007 document file to event object.

Here is my code

...
...
DDay.iCal.iCalendar iCal = new DDay.iCal.iCalendar();
DDay.iCal.Components.Event iCalEvent = iCal.Create<DDay.iCal.Components.Event>();

Binary[] binAttachList = new Binary[1];
binAttachList[0] = new Binary();
binAttachList[0].AddParameter("X-FILENAME", activity.Attachment.DisplayName);
binAttachList[0].AddParameter("VALUE", "BINARY");
binAttachList[0].SetEncoding(EncodingType.Base64);
binAttachList[0].Data = Read(@“C:\Temp\MyFile.doc”);

iCalEvent.Attach = binAttachList;
...
...

private static byte[] Read(string fileName)
{
using (FileStream reader = new FileStream(fileName, FileMode.Open))
{
byte[] binaryData = new byte[reader.Length];
reader.Read(binaryData, 0, (int)reader.Length);
return binaryData;
}
}

The file does get attached, but if I open it in Office Word again it doesn’t open.

What am I doing wrong? Could you please help me solve this problem?
GeneralRe: Attachment ProblemmemberDouglas Day8-Dec-08 5:58 
This problem has been fixed in the development version of the code, and will be included in the next release.
 
Thanks,
-Doug
GeneralView by Month, Week, DaymemberTommy Johnston6-Nov-08 6:10 
Thanks for this Article/Software package. It looks like it will help me accomplish a goal of getting Outlook Calendars viewable through our Intranet.
 
This example gives an option to show data for the current day, and for the next 7. I'd like to use the ASP.NET Calendar Object to give users an option to choose a date in the past/future to view. Idealy I'd like to have a Monthly view that would show Events for all 30-31 days, for any month in the future.
 
I'd like to emulate the Outlook interface as closely as possible. Can anybody point me in the right direction?
 
Thanks,
 
Tommy
GeneralError When Trying to Access Data in iCalendar Filememberjdcurtis20-Jun-08 10:58 
Hi,
Thanks for creating a great icalendar class library. I have one quick question. I'm parsing iCalendar files and some VEVENTS have DESCRIPTION items and some don't. If I try and get the DESCRIPTION from a VEVENT that doesn't have a value defined I get the following error message:
 

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at DDay_iCal_TEST.Program.Main(String[] args) in C:\...\Program.cs:line 57
Press any key to continue . . .
 
Here's line 57:
strEventDescription = evt.Description.ToString();
 
Do you have any suggestions on how I can handle situations where some VEVENTS have items like DESCRIPTION and some don't?
 
Thanks.
QuestionFrequencyOccurrence use ?memberElcado21-May-08 1:07 
Hi,
 
i'm trying to convert palm calendar into iCalendar equivalent (for a HotSync conduit), and i meet some difficulties in the use of FrequencyOccurrence for recurrent events, using a DaySpecifier object embedded in the ByDay property of a RecurrencePattern object. For example (record is my palm event object):
RecurrencePattern recPattern = new RecurrencePattern();
recPattern.ByDay.Add(new DaySpecifier(record.StartTime.DayOfWeek, FrequencyOccurrence.First));
 
Here is my problem: it seems that FrequencyOccurrence enumeration doesn't contain a Fourth statement:
public enum FrequencyOccurrence
    {
        None = -2147483648,
        ThirdToLast = -3,
        SecondToLast = -2,
        Last = -1,
        First = 1,
        Second = 2,
        Third = 3,
    }
which is neccessary if the day of the event appears five times in the month.
 
Thank you for you great work !!
QuestionHow to create a Todo with an Alarm?memberLAURENT JP31-Jan-08 3:43 
When I create an alarm in an Todo, I get an exception in Serializer.
 
How to create an alarm with DateTime set ?
 
Thanks.
QuestionNet Framework 1.1 Support?memberCarlosSV17-Dec-07 6:19 
First, thanks for the grat job.
 
Second, is supportted the net framework 1.1?
 
Thanks a lot.
GeneralRe: Net Framework 1.1 Support?memberDouglas Day14-Jan-08 10:01 
Sorry for the delay in answering. No, the lowest version of the framework supported is .NET 2.0. Also, the Compact Framework is not supported, though this may be a feature that could be added in the future.
QuestionAny VB examples?memberGracie Diaz22-Oct-07 7:11 
Are there any examples written in VB? Has anyone converted example 5 into VB at all?
QuestionGreat jobmemberadc0814-Oct-07 22:27 
Hi,
thanks exactly what I have been looking for.
 
Just a question :
 
Here is some samples on save ical into sql database.
but there is no one to load an ical whit data (string) stored in sql.
 
Do I have to create a temporaly ics file whit the serialised data in sql before load it ?
 
thanks again
David.

AnswerRe: Great jobmemberrakeshg32121-Oct-07 18:42 
Douglas,
 
Can you kindly provide us some sample code to read the iCalText from the database. I can store my calendar with events using Serializer class in the database, as suggested by you in your previous message, but when I try to read it from the database using either "iCalendar.LoadFromStream" or "serializer.Deserialize" methods I get the following error
antlr.MismatchedTokenException: expecting "CRLF", found ' '
 
serializer.Deserialize expects TextReader as parameter and I use the following to read string into textreader
TextReader trMyCal = new StringReader(str_iCal);
 
iCalendar.LoadFromStream expects Stream object as parameter and I use the following to initialize my Stream object
Stream myStreamCalText = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(str_iCal));
 
I suspect the new line characters are getting replaced with 2 empty spaces when being store in the database. I tried to replace " " string in my str_iCal with "\r\n" but that does not work either
 
I am storing serializer.SerializeToString() in nText field of SQL 2005 database.
 
Thanks for the good work. I appreciate your help
 
-Rakesh
QuestionAPImemberKeith Farmer27-Sep-07 22:06 
Great work -- I'm glad I didn't have to write this.
 
One suggestion, though: add GetRecurrences(start, end|timespan) & GetRecurrences(date) methods that perform the Evaluate and return an enumeration of the recurrences within that period in order (eg by ascending start datetime & descending duration). This would greatly reduce code in very common scenarios.
 

 
-----
Keith J. Farmer [MSFT:VC#/DLinq]

AnswerRe: APImemberDouglas Day1-Oct-07 18:58 
Thanks!
 
That's a good idea - one that many people have noted. Methinks I'll add it to the next major release Smile | :) I actually like the GetRecurrences() methodology. Anyhow, thanks for the note.
 
Regards,
-Doug
GeneralThanks and a QuestionmemberChristopherN2-Aug-07 3:48 
This article and your code are both great! I am planning to use your library to schedule some jobs and I want to store the events in SQL Server. I have seen the thread were you showed someone how to serialze and store the calendar in a DB. My needs are different: I need to poll the calendar and find events that fit within a small timespan to kick-off jobs. The db will be polled on a timer and I am concerned about performance. I think that defining a db schema that mirrors the iCal schema and storing each scheduled event as a record (or several records if needed) will ease the querying of the data. The only time I would need to structure the data in ICS format is when a user wants to export their scheduled jobs to their personal calendar client. Do you think that creating a db schema based on your library/iCal/ICS is the right way to go?
GeneralRe: Thanks and a QuestionmemberDouglas Day2-Aug-07 15:50 
Christopher,
 
Yes, I would use the ICS format for scheduled jobs, but I see no need to duplicate the ICS format in the database. Really, all you'd need to do is detect changes in your ICS file (via some sort of hash, or by using the iCalendar's LastModified property), and then re-evaluate your recurrences whenever the iCalendar changes.
 
From my perspective, all you'd need to do is store a list of Date/Times when the event recurs, the iCalendar where the event is stored, and the UID of the event, in a recurrence table in the database. Then, in another database table, you can store the actual iCalendar text. When querying the recurrence table, and finding an event that needs some action taken, you can then load the corresponding iCalendar and take action based on the event.
 
So, when the iCalendar file changes, you'd clear out the recurrences in your recurrence table in the database, and repopulate it via the iCalendar file. Of course, you'll only want to populate a given period in the future, and will periodically need to calculate future occurrences (once monthly, perhaps?)
 
Anyhow, that's what I'd do.
 
Let me know if you have more questions, or if you'd like me to clarify further.
 
Thanks,
-Doug
GeneralRe: Thanks and a Question [modified]memberChristopherN6-Aug-07 3:53 
RE: "all you'd need to do is store a list of Date/Times when the event recurs, the iCalendar where the event is stored, and the UID of the event, in a recurrence table in the database"
Yes, that is the direction that I have been going in. Thanks!
 
On another note, is there any XML support in your library? I don't see anything. Part of what I am working on requires a web service where iCal data will be used by the web methods. I vaguely remember seeing an XSD somewhere for iCal but don't remeber if it was a standard or an individual's implementation. I could write a schema myself, but would prefer a standard and would like it to work easily with your library. Any thoughts?
 
Thanks,
Chris
 

-- modified at 9:12 Tuesday 7th August, 2007
GeneralRe: Thanks and a QuestionmemberDouglas Day26-Aug-07 10:27 
Chris,
 
Sorry in the delay in answering.
 
There is currently no support for an XML format in DDay.iCal, however, I have been putting a significant amount of effort into abstracting the serialization mechanisms in DDay.iCal to support any type of format (namely, xCal). There has been enough demand for an xCal format to move this forward. The only problem is that I'm short on time these days. It may take several months to get the xCal format built into DDay.iCal. I'll try to get this done ASAP.
 
Thanks,
-Doug
GeneralRe: Thanks and a QuestionmemberDouglas Day1-Oct-07 19:04 
One option is to BASE64 encode the iCalendar, so it will be XML-compliant. Also, I've been working on the xCal standard for DDay.iCal, so I'm hoping it will be complete within the next month or so. Anyhow, it will be complete once it passes all of the unit tests.
 
Thanks,
-Doug
GeneralRe: Thanks and a Questionmemberkneckedeck27-Mar-09 4:02 
Hi!
 
Seems that you've put the xml-compliance on hold. It's a pity, it would have been very useful and would also make your project more "complete".
 
Any news regarding this? Will you keep developing this project? Can we expect any updates in the near future?
 
And thanks for a very nice article and project! Good work! Smile | :)
GeneralRe: Thanks and a QuestionmemberDouglas Day27-Mar-09 5:44 
Hi,
 
Yes, I've had so many other projects that are keeping my attention that I haven't had a chance to push forward the xCal serialization. This is still on the slate, as it would be useful in many scenarios. I am still working on the project, albeit slowly. The major direction of DDay.iCal currently is in development of iCalendar validation. See http://icalvalid.wikidot.com/[^].
 
If you have suggestions of directions to take the project, or feature requests, please use the SourceForge.net project page[^.
 
Thanks!!
-Doug
Generalwindows mobilememberCeline97112-Jun-07 3:17 
Hello!
 
Very good!!!
 
Can I use Icalendar on windows mobile?
or else, is there any ical's free version for windows mobile?
 
Thank you for your response
 
Céline
AnswerRe: windows mobilememberDouglas Day2-Aug-07 15:52 
Sorry about the wait - I've answered this question before in the SourceForge forums, but I thought I'd answer here also, to save people time.
 
No, DDay.iCal does not currently support the .NET Compact Framework. I've thought about supporting this in the future, but this does not fit into my plans for the near future.
 
Thanks,
-Doug
Generalwebsite downloadmemberrobroll9-May-07 10:17 
How can I generate the ical file dynamically and send it to the users browser for download?
 
Great project! This code has really helped me.
thanks.
GeneralRe: website downloadmemberDouglas Day2-Aug-07 15:53 
Yes, you sure can.
 
You can serialize the iCalendar to the output stream of your web page. All you'd need to do is make sure you set the mime type to "application/calendar", and it should behave properly.
 
Thanks,
-Doug
 
(Sorry about the delay in answering)
GeneralGoooooooooooooDmemberStiven Wang21-Mar-07 22:11 
Very helpful for learning iCalendar format. Thanks. By the way, do you have any plan for next release for can create/modify the schedule..?Smile | :)
GeneralRe: GoooooooooooooDmemberDouglas Day22-Mar-07 5:00 
Thanks!
 
I'll be writing another article in the next several weeks that describes how to create/modify items. DDay.iCal is already capable of this, though. If you download the full DDay.iCal package from SourceForge, there are some examples of adding/modifying items to calendars.
 
If you have any other questions, please let me know.
 
-Doug
GeneralVery nicememberDan Letecky13-Mar-07 3:30 
Very nice! You get my 5.
 
--
My sites for smart .NET developers:
DayPilot - Open-source Outlook-like calendar control for ASP.NET
DotLucene - The fastest open source fulltext search engine for .NET
MenuPilot - Open-source task menu for ASP.NET 2.0
Seekafile Server - Flexible open-source search server
DotNetFirebird

Questionloading from SQL databasemembercoshishonour12-Mar-07 19:44 
Hi, firstly, gr8 article.
 
However, I would like to save the iCal information for every user of my app in a SQL 2000 database. Can you provide me with the basic information on how to go about it. Or have anyy links that have a tut.
I've checked the project's website & wikipedia. Didnot find any tut on how to do this.
 
Thnx 4 the wonderful article.

AnswerRe: loading from SQL databasememberDouglas Day13-Mar-07 4:33 
Thanks!
 
First of all, I'll try to get my next article out quickly, which talks about more advanced concepts like serialization and customization. I'm also working on some in-depth documentation and tutorials for my web site.
 
Anyway, that said, here's how I would do it:
 
First, include the DDay.iCal.Serialization namespace:
using DDay.iCal.Serialization;
Then, you can do something like the following:
// Create a new iCalendar
iCalendar iCal = new iCalendar();
 
// Add an event to the iCalendar
Event evt = iCal.Create<Event>();
evt.Summary = "My event summary";
evt.Start = DateTime.Now;
 
// Create a serialization object
iCalendarSerializer serializer = new iCalendarSerializer(iCal);
 
// Serialize the calendar into a string object
string iCalendarString = serializer.SerializeToString();
 
SqlConnection connection = new SqlConnection("...connectionstring...");
 
// You'll want to customize this command to your database
SqlCommand cmd = new SqlCommand(@"
INSERT INTO myTable(Username, iCalendarString)
VALUES (@uid, @str)", connection);
 
// Add our custom parameters to the query...
// It's safer to build your SQL query this way,
// so things like a single quote ' character
// don't mess up your query.
cmd.Parameters.Add("@uid", SqlDbType.VarChar);
cmd.Parameters.Add("@str", SqlDbType.VarChar);
cmd.Parameters["@uid"].Value = ...username...;
cmd.Parameters["@str"].Value = iCalendarString;
 
try
{
    connection.Open();
    cmd.ExecuteNonQuery();
    connection.Close();
}
catch(Exception ex)
{
    ... catch errors ...
}
Let me know if you have any more questions or problems,
 
-Doug
GeneralRe: loading from SQL databasemembercoshishonour14-Mar-07 8:46 
Thnx 4 the quick reply Doughlas,
 
I think this should work. My initial worry was the structure of the table(s) in case I wanted to save the .ics file in a database. Mapping all objects to fields & doing tht correctly was my biggest worry.
 
Kinda busy this week, but'll definitely start work on this by monday.
I was planning a calendar/to-do/events framework @ an enterprise level where there is one enterprise calendar (common for the entire office), every user can create his/her personal appointments/events/to-do lists and has the ability to send a selected set of events to other users (lets say a manager to his team, detailing the target dates for the entire year).
 
Will let U know as I proceed.
 
Thnx again for the help.
GeneralRe: loading from SQL databasememberDougNichols14-Jul-08 11:42 
First off thanks for the great library.
 
I am sort of hijacking this thread because my question has a lot to do with SQL Server. In this example you posted you are writing the iCalendar to the database. My question is how to retrieve it back out correctly? The only ways I see of loading the iCalendar is from the filestream. Is there a way of getting the text back out of the database and then creating the calendar object from that?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 14 Apr 2010
Article Copyright 2007 by Douglas Day
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid