Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create an "internet calendar subscription" for Outlook?

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.

like image 811
whodares Avatar asked May 29 '13 11:05

whodares


People also ask

How do I add internet calendar to my Outlook calendar?

Add internet calendarsOpen your Outlook calendar, select Add > From Internet. Paste the URL from your internet calendar and select OK. Outlook asks if you would like to add this calendar and subscribe to updates. Select Yes.

What is Outlook internet calendar subscription?

Subscribe to a Calendar in Outlook This will allow you to keep up with the schedule, but also any changes that happen to the calendar. Simply importing calendar entries will not accomplish the task.


1 Answers

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);
}
like image 87
JP Hellemons Avatar answered Sep 18 '22 22:09

JP Hellemons