ISchedulerStorageBase.CreateOutlookImporter() Method
Creates an object which allows you to control how data is imported from MS Outlook’s Calendar.
Namespace: DevExpress.XtraScheduler
Assembly: DevExpress.XtraScheduler.v24.1.Core.dll
NuGet Package: DevExpress.Scheduler.Core
Declaration
Returns
Type | Description |
---|---|
AppointmentImporter | An object which can import data from MS Outlook’s Calendar. |
Remarks
Although you can import data from Outlook’s Calendar via the ISchedulerStorageBase.ImportFromOutlook method, use the CreateOutlookImporter method to control how appointments are retrieved from MS Outlook’s Calendar. Call this method to create an AppointmentImporter object, and subscribe to its events to control import operations.
Note
For data synchronization use the AppointmentSynchronizer class descendant instead. It is created by ISchedulerStorageBase.CreateOutlookImportSynchronizer method. Refer to Synchronization with Microsoft Outlook article for more information.
Example
This code illustrates how to use the OutlookImport class to manage the process of importing appointments from MS Outlook. Use the SchedulerDataStorage.CreateOutlookImporter method to create the importer, subscribe to its AppointmentImporter.AppointmentImporting, AppointmentImporter.AppointmentImported and AppointmentExchanger.OnException events and call the AppointmentImporter.Import method.
private void ImportUsingCriteria() {
OutlookImport importer = schedulerControl1.Storage.CreateOutlookImporter() as OutlookImport;
if (importer != null) {
importer.AppointmentImporting += importer_AppointmentImporting;
importer.AppointmentImported += importer_AppointmentImported;
importer.OnException += importer_OnException;
importer.CalendarFolderName = OutlookExchangeHelper.GetOutlookCalendarFolders().FirstOrDefault().FullPath;
using (MemoryStream stream = new MemoryStream()) {
importer.Import(stream);
}
}
}
void importer_AppointmentImporting(object sender, AppointmentImportingEventArgs e) {
OutlookAppointmentImportingEventArgs args = e as OutlookAppointmentImportingEventArgs;
AddToLog(String.Format("Importing Subj:{0}, started at {1:F} ...", args.OutlookAppointment.Subject, args.OutlookAppointment.Start));
if (args.OutlookAppointment.BusyStatus == DevExpress.XtraScheduler.Outlook.Interop.OlBusyStatus.olWorkingElsewhere) {
e.Cancel = true;
AddToLog("Cancelled because of its busy type (working elsewhere).");
}
}
void importer_AppointmentImported(object sender, AppointmentImportedEventArgs e) {
OutlookAppointmentImportedEventArgs args = e as OutlookAppointmentImportedEventArgs;
AddToLog(String.Format("Successfully imported Subj:{0}, started at {1:F}!", args.OutlookAppointment.Subject, args.OutlookAppointment.Start));
}
void importer_OnException(object sender, ExchangeExceptionEventArgs e) {
string errText = e.OriginalException.Message;
AddToLog(errText);
OutlookImport importer = (OutlookImport)sender;
importer.Terminate();
e.Handled = true;
//throw e.OriginalException;
}