static void WriteAppointments(XmlTextWriter xmlWriter)
        {
            string[] rooms = GetWatchingRooms();

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement("Appointments");
            xmlWriter.WriteElementString("ImportTime", DateTime.Now.ToString());

            isError = false;

            foreach (string room in rooms)
            {
                try
                {
                    data.ScheduleData roomAppointments = ExchangeHelper.LoadResouceCallendar(room);
                    WriteRoomXml(roomAppointments, xmlWriter);
                }
                catch (Exception ex)
                {
                    isError = true; // Set error flag to prevent caching
                    Trace.TraceError("Error writing appointments for room {0} ErrMsg: {1}", room, ex.Message);
                    xmlWriter.WriteStartElement("Error");
                    xmlWriter.WriteAttributeString("Room", room);
                    xmlWriter.WriteStartElement("Message", ex.Message);
                    xmlWriter.WriteStartElement("Trace");
                    xmlWriter.WriteCData(ex.StackTrace);
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndElement();
                }
            }

            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
        }
        /// <summary>
        /// Export appointments into xml file
        /// </summary>
        /// <param name="Appointments"></param>
        static void WriteRoomXml(data.ScheduleData roomSchedule, XmlTextWriter writer)
        {
            foreach (data.Appointment appointment in roomSchedule.Schedule)
            // foreach (Appointment appointment in Appointments)
            {
                writer.WriteStartElement("Appointment");
                writer.WriteElementString("StartTime", appointment.StartTime);
                writer.WriteElementString("EndTime", appointment.EndTime);
                writer.WriteElementString("Title", appointment.Title);
                writer.WriteElementString("Location", appointment.Location);
                writer.WriteElementString("Category", appointment.Category);

                // Try to read Lync meeting URL

                writer.WriteEndElement();
            }
        }