This is a migrated thread and some comments may be shown as answers.

Creating a ScheduleView that synchronizes with Outlook

0 Answers 123 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 16 May 2016, 05:25 AM

Hi,

At the moment, upon loading my usercontrol, I programatically load all my calendar events. I export my outlook calendar folder then import it into the schedule view. I'm wondering what is the best approach to integrate with outlook? I created methods to trigger OnAppointmentDelete and OnAppointmentCreate, such that it'll update outlook. But is this the ideal solution? 

 

        private void LoadOutlook()
        {
            try
            {
                var outlook = new ApplicationClass();
                var OutlookNS = outlook.GetNamespace("MAPI");

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

                CalendarSharing cs = f.GetCalendarExporter();
                cs.CalendarDetail = OlCalendarDetail.olFullDetails;
                cs.StartDate = new DateTime(2011, 11, 1);
                cs.EndDate = new DateTime(2018, 12, 31);
                var tempPath = Path.GetTempPath();
                var tempCalendar = tempPath + "cal.ics";
                cs.SaveAsICal(tempCalendar);
                using (TextReader txtReader = new StreamReader(tempCalendar))
                {
                    this.Import(txtReader);
                }
            }
            catch
            {
                
            }
        }

No answers yet. Maybe you can help?

Tags
ScheduleView
Asked by
Minh
Top achievements
Rank 1
Share this question
or