Skip to main content

SchedulerStorageBase.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.Desktop.dll

Declaration

public virtual AppointmentExporter CreateOutlookExporter()

Returns

Type Description
AppointmentExporter

An AppointmentExporter object which can export data to MS Outlook’s Calendar.

Remarks

Use the SchedulerStorageBase.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 AppointmentSynchronizer class descendant instead. It is created by SchedulerStorageBase.CreateOutlookExportSynchronizer method. Refer to 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;
}
See Also