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
{
}
}