繁体   English   中英

C#Outlook VSTO如何将日历导出到ics或vcs文件?

[英]C# Outlook VSTO How to export the calendar to ics or vcs file?

大家好

这里有任何教程如何将范围从1 Yeahr的日历导出为vcs和ics文件?

我已经尝试过的

OutlookNS = outlook.GetNamespace("MAPI");

Outlook.MAPIFolder f = OutlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

Outlook.CalendarSharing cs = f.GetCalendarExporter();
cs.CalendarDetail = Outlook.OlCalendarDetail.olFullDetails;
cs.StartDate = new DateTime(2015, 11, 1);
cs.EndDate = new DateTime(2016, 12, 31);
cs.SaveAsICal(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\calender.ics");

我得到的错误:

The object reference was not set to an object instance

那我该怎么办请帮帮我:)

起作用的代码:

        OutlookNS = Globals.ThisAddIn.Application.GetNamespace("MAPI");
        Outlook.MAPIFolder f = OutlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
        Outlook.CalendarSharing cs = f.GetCalendarExporter();
        cs.CalendarDetail = Outlook.OlCalendarDetail.olFullDetails;
        cs.StartDate = new DateTime(2015, 11, 1);
        cs.EndDate = new DateTime(2016, 12, 31);
        cs.SaveAsICal(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\kalender.ics");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM