asp.net-mvc-4 - 如何为 Outlook 创建 "internet calendar subscription"?

标签 asp.net-mvc-4 outlook icalendar

目前,用户添加了“新的 Internet 日历”,但它是一次性下载 ICS 文件。我希望用户单击一个按钮将他的个人日历添加为 Outlook 订阅。我要自动更新 "internet calendar subscription" .

就像在 SharePoint 中一样,名为“连接到 Outlook”的按钮会将您正在查看的日历作为自动同步日历添加到您的 Outlook 中。

最佳答案

Creating iCals in C#this CodeProject post告诉我你应该使用 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.



一些 sample code 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);
}

关于asp.net-mvc-4 - 如何为 Outlook 创建 "internet calendar subscription"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16812921/

相关文章:

android - 使用 Android 返回 405 的 Get 方法请求 MVC4 WEB API

javascript - 在 MVC4 的 Controller 内调用 Javascript 表单

c# - 从虚拟目录下载文件

html - 在 Outlook 中打开 .OFT 的超链接

email - 从 Outlook::Attachment(嵌入式电子邮件)获取 Outlook::_MailItem

Excel 宏卡住 Outlook

outlook-2007 - _Really_ 通过 Outlook 中的 ics 禁用提醒

c# - 使用语句不起作用 - VS 2012

php - 将 iCal 日历导入 MySQL 数据库

javascript - 在 Phonegap 中处理 .ICS 文件