public static void ExportIcal(string path)
        {
            var oApp          = new Application();
            var mapiNamespace = oApp.GetNamespace("MAPI");;

            MAPIFolder f = mapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

            CalendarSharing cs = f.GetCalendarExporter();

            cs.CalendarDetail = OlCalendarDetail.olFullDetails;
            cs.StartDate      = DateTime.Now.AddDays(-7);
            cs.EndDate        = DateTime.Now.AddMonths(2);
            cs.SaveAsICal(path);
        }
Beispiel #2
0
        // export current calendar to ics formatted file
        static void exportICal()
        {
            Application outlook;
            NameSpace   OutlookNS;

            outlook   = new Application();
            OutlookNS = outlook.GetNamespace("MAPI");

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

            CalendarSharing cs = f.GetCalendarExporter();

            cs.CalendarDetail         = OlCalendarDetail.olFreeBusyOnly;
            cs.StartDate              = refStartOfWeek;
            cs.EndDate                = refEndOfWeek;
            cs.RestrictToWorkingHours = true;

            string _saveFileLoc = getDesktopFilePath(true);

            sendToConsole(defaultColor, string.Format(@"iCalendar file saved to: {0}", _saveFileLoc));
            cs.SaveAsICal(_saveFileLoc);
        }