Back to Devexpress

How to: Export Appointment as a Meeting Request with Attendees

windowsforms-8761-controls-and-libraries-scheduler-examples-data-exchange-how-to-export-appointment-as-a-meeting-request-with-attendees.md

latest4.0 KB
Original Source

How to: Export Appointment as a Meeting Request with Attendees

  • Nov 13, 2018
  • 2 minutes to read

The following code handles the AppointmentExporter.AppointmentExporting event of the iCalendarExporter. It uses the iCalendarComponentBase.CustomProperties property of the current VEvent object, accessible via the iCalendarAppointmentExportingEventArgs.VEvent property of the event arguments, to add addresses of the attendees to the exported object. So, the exported object is no longer an appointment, but a meeting request with attendees.

csharp
using DevExpress.XtraScheduler.iCalendar;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.iCalendar.Components;
        void ExportAppointments(Stream stream) {
            if (stream == null)
                return;
            iCalendarExporter exporter = new iCalendarExporter(schedulerStorage1);
            exporter.AppointmentExporting += 
                new AppointmentExportingEventHandler(exporter_AppointmentExporting);
            exporter.Export(stream);
        }
        void exporter_AppointmentExporting(object sender, AppointmentExportingEventArgs e) {
            string s = Convert.ToString(e.Appointment.CustomFields[RecipientsDataColumn]);
            string[] attendees = s.Split(';');

            iCalendarAppointmentExportingEventArgs args = e as iCalendarAppointmentExportingEventArgs;
            AddEventAttendees(args.VEvent, attendees);
        }
        private void AddEventAttendees(VEvent ev, string[] addresses) {
            int count = addresses.Length;
            for (int i = 0; i < count; i++)
                AddEventAttendee(ev, addresses[i]);
        }
        private void AddEventAttendee(VEvent ev, string address) {
            TextProperty p = new TextProperty("ATTENDEE", 
                String.Format("mailto:{0}", address));
            p.AddParameter("CN", address);
            p.AddParameter("RSVP", "TRUE");
            ev.CustomProperties.Add(p);
        }
vb
Imports DevExpress.XtraScheduler.iCalendar
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.iCalendar.Components
        Private Sub ExportAppointments(ByVal stream As Stream)
            If stream Is Nothing Then
                Return
            End If
            Dim exporter As New iCalendarExporter(schedulerStorage1)
            AddHandler exporter.AppointmentExporting, AddressOf exporter_AppointmentExporting
            exporter.Export(stream)
        End Sub
        Private Sub exporter_AppointmentExporting(ByVal sender As Object, ByVal e As AppointmentExportingEventArgs)
            Dim s As String = Convert.ToString(e.Appointment.CustomFields(RecipientsDataColumn))
            Dim attendees() As String = s.Split(";"c)

            Dim args As iCalendarAppointmentExportingEventArgs = TryCast(e, iCalendarAppointmentExportingEventArgs)
            AddEventAttendees(args.VEvent, attendees)
        End Sub
        Private Sub AddEventAttendees(ByVal ev As VEvent, ByVal addresses() As String)
            Dim count As Integer = addresses.Length
            For i As Integer = 0 To count - 1
                AddEventAttendee(ev, addresses(i))
            Next i
        End Sub
        Private Sub AddEventAttendee(ByVal ev As VEvent, ByVal address As String)
            Dim p As New TextProperty("ATTENDEE", String.Format("mailto:{0}", address))
            p.AddParameter("CN", address)
            p.AddParameter("RSVP", "TRUE")
            ev.CustomProperties.Add(p)
        End Sub