7

Currently, the user adds a "new internet calendar", but it's a one-time download of the ICS file. I want the user to click a button to get his personal calendar added as a subscription to Outlook. I want the automatically updating "internet calendar subscription".

Like in SharePoint, the button called "Connect to Outlook" which adds the calendar you're viewing to your Outlook as an automatically syncing calendar.

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
whodares
  • 676
  • 4
  • 11
  • 28

1 Answers1

6

Creating iCals in C# and this CodeProject post tell me you should use the DDay iCal Library.

DDay.iCal is an iCal (RFC 5545) class library for .NET 2.0 and above, Silverlight. It aims at being as RFC 5545 compliant as possible, while targeting compatibility with popular calendaring applications, like Apple iCal, Outlook 2007, etc.

Some sample code of iCal + MVC + DDay.iCal

public ActionResult iCalendar(string DownloadFileName)
{
    DDay.iCal.iCalendar iCal = new DDay.iCal.iCalendar();

    Event evt = iCal.Create<Event>();
    evt.Start = iCalDateTime.Today.AddHours(8);
    evt.End = evt.Start.AddHours(18); // This also sets the duration
    evt.Description = "The event description";
    evt.Location = "Event location";
    evt.Summary = "18 hour event summary";

    evt = iCal.Create<Event>();
    evt.Start = iCalDateTime.Today.AddDays(5);
    evt.End = evt.Start.AddDays(1);
    evt.IsAllDay = true;
    evt.Summary = "All-day event";

    ISerializationContext ctx = new SerializationContext();
    ISerializerFactory factory = new DDay.iCal.Serialization.iCalendar.SerializerFactory();
    IStringSerializer serializer = factory.Build(iCal.GetType(), ctx) as IStringSerializer;

    string output = serializer.SerializeToString(iCal);
    var contentType = "text/calendar";
    var bytes = Encoding.UTF8.GetBytes(output);

    return File(bytes, contentType, DownloadFileName);
}
Community
  • 1
  • 1
JP Hellemons
  • 5,977
  • 11
  • 63
  • 128
  • First of all thank you for commenting. My application already has a stream which gives me the ics file for my outlook. The problem is tha the user has to add the link manually in outlook via add calendar => from internet. I'm trying to fix this with a single button click. I also found the dday ical and that's how our ics file is being generated now. – whodares May 29 '13 at 11:48
  • Perhaps this hotfix can help out. http://stackoverflow.com/questions/4349836/how-can-i-add-an-ics-meeting-automatically-to-the-organizers-calendar because when you click on the ical, it should be opened in outlook by default (if installed of course) – JP Hellemons May 29 '13 at 11:50
  • The problem is not that outlook doesn't open it. the problem is that I want to add an INTERNET calendar and not just a one-time ics-file. When I just let it generate and add the ics file manually, I don't get the internet updates anymore. – whodares May 29 '13 at 11:54
  • 1
    I do not understand how that could help me with it becoming an internet calendar. Could you please explain what the difference between .ics and .ical is? I switched it over on my local testproject and it changed absolutely nothing to the result. – whodares May 29 '13 at 12:14
  • should work if you add an `ORGANIZER` http://stackoverflow.com/questions/4137437/update-event-in-outlook-via-ics-file more also on this url http://stackoverflow.com/questions/12112323/create-outlook-appointment-with-dday-library-as-opposed-to-meeting-request – JP Hellemons May 29 '13 at 12:34
  • I must have missed something since I still don't understand how those examples have anything to do with adding an internet calendar. My stream is read-only (own choice) so users will never be able to alter it. They can't update or add events to the stream itself. I'd like to ask you to take a better look at what I'm asking. My stream is ready. It does what it's supposed to do. All I want is for my user to skip the "open calendar => from internet" dialogues in outlook. – whodares May 29 '13 at 12:45