corelibraries-devexpress-dot-xtrascheduler-dot-schedulerstoragebase-af8bae58.md
Creates an object which provides the capability to control how data is exported to MS Outlook’s Calendar.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.Core.Desktop.dll
NuGet Package : DevExpress.Scheduler.CoreDesktop
public virtual AppointmentExporter CreateOutlookExporter()
Public Overridable Function CreateOutlookExporter As AppointmentExporter
| Type | Description |
|---|---|
| AppointmentExporter |
An AppointmentExporter object which can export data to MS Outlook’s Calendar.
|
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.
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;
}
Private Sub ExportUsingCriteria()
Dim exporter As OutlookExport = TryCast(schedulerControl1.Storage.CreateOutlookExporter(), OutlookExport)
If exporter IsNot Nothing Then
AddHandler exporter.AppointmentExporting, AddressOf exporter_AppointmentExporting
AddHandler exporter.AppointmentExported, AddressOf exporter_AppointmentExported
AddHandler exporter.OnException, AddressOf exporter_OnException
exporter.CalendarFolderName = OutlookExchangeHelper.GetOutlookCalendarFolders().FirstOrDefault().FullPath
Using stream As New MemoryStream()
exporter.Export(stream)
End Using
End If
End Sub
Private Sub exporter_AppointmentExporting(ByVal sender As Object, ByVal e As AppointmentExportingEventArgs)
AddToLog(String.Format("Exporting Subj:{0}, started at {1:F} ...", e.Appointment.Subject, e.Appointment.Start))
If e.Appointment.IsRecurring Then
e.Cancel = True
AddToLog("Cancelled because of its type (recurring).")
End If
End Sub
Private Sub exporter_AppointmentExported(ByVal sender As Object, ByVal e As AppointmentExportedEventArgs)
AddToLog(String.Format("Successfully exported Subj:{0}, started at {1:F}!", e.Appointment.Subject, e.Appointment.Start))
End Sub
Private Sub exporter_OnException(ByVal sender As Object, ByVal e As ExchangeExceptionEventArgs)
Dim errText As String = e.OriginalException.Message
AddToLog(errText)
Dim exporter As OutlookExport = DirectCast(sender, OutlookExport)
exporter.Terminate()
e.Handled = True
'throw e.OriginalException;
End Sub
See Also
CreateOutlookExportSynchronizer()