ISchedulerStorageBase.CreateOutlookExporter() Method
Creates an object which provides the capability to control how data is exported to MS Outlook’s Calendar.
Namespace: DevExpress.XtraScheduler
Assembly: DevExpress.XtraScheduler.v24.2.Core.dll
Declaration
Returns
Type | Description |
---|---|
AppointmentExporter | An AppointmentExporter object which can export data to MS Outlook’s Calendar. |
Remarks
Although you can use the ISchedulerStorageBase.ExportToOutlook method for data export to MS Outlook’s Calendar, use the CreateOutlookExporter method if you need to control how appointments are posted to the MS Outlook’s Calendar. Call this method to create an AppointmentExporter object and subscribe to its events to control export operations.
Note
For data synchronization, use the AppointmentSynchronizer class descendant instead. It is created by the ISchedulerStorageBase.CreateOutlookExportSynchronizer method. Refer to the Synchronization with Microsoft Outlook article for more information.
Example
This code illustrates how to use the OutlookExport class to manage the process of exporting appointments to MS Outlook. Use the SchedulerDataStorage.CreateOutlookExporter method to create the exporter, subscribe to its AppointmentExporter.AppointmentExporting, AppointmentExporter.AppointmentExported and AppointmentExchanger.OnException events and call the AppointmentExporter.Export method.
private void ExportUsingCriteria() {
OutlookExport exporter = schedulerControl1.Storage.CreateOutlookExporter() as OutlookExport;
if (exporter != null) {
exporter.AppointmentExporting += exporter_AppointmentExporting;
exporter.AppointmentExported += exporter_AppointmentExported;
exporter.OnException += exporter_OnException;
exporter.CalendarFolderName = OutlookExchangeHelper.GetOutlookCalendarFolders().FirstOrDefault().FullPath;
using (MemoryStream stream = new MemoryStream()) {
exporter.Export(stream);
}
}
}
void exporter_AppointmentExporting(object sender, AppointmentExportingEventArgs e) {
AddToLog(String.Format("Exporting Subj:{0}, started at {1:F} ...", e.Appointment.Subject, e.Appointment.Start));
if (e.Appointment.IsRecurring) {
e.Cancel = true;
AddToLog("Cancelled because of its type (recurring).");
}
}
void exporter_AppointmentExported(object sender, AppointmentExportedEventArgs e) {
AddToLog(String.Format("Successfully exported Subj:{0}, started at {1:F}!", e.Appointment.Subject, e.Appointment.Start));
}
void exporter_OnException(object sender, ExchangeExceptionEventArgs e) {
string errText = e.OriginalException.Message;
AddToLog(errText);
OutlookExport exporter = (OutlookExport)sender;
exporter.Terminate();
e.Handled = true;
//throw e.OriginalException;
}