How to: Export Appointment as a Meeting Request with Attendees
- 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.
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);
}