public ReserveRoomResponse Execute(ReserveRoomRequest request) { var response = new ReserveRoomResponse(); try { // Get mailbox info var requestMailboxInfo = new GetMailboxInfo.GetMailboxInfoRequest( email: request.MailboxEmail); var responseMailboxInfo = new GetMailboxInfo().Execute(requestMailboxInfo); if (!responseMailboxInfo.Success) { response.ErrorMessage = responseMailboxInfo.ErrorMessage; return response; } // Connect to Exchange var service = ExchangeServiceConnector.GetService(request.MailboxEmail); var mbx = new Mailbox(request.MailboxEmail); FolderId fid = new FolderId(WellKnownFolderName.Calendar, mbx); //CalendarFolder calendar = CalendarFolder.Bind(service, fid, new PropertySet(FolderSchema.ManagedFolderInformation, FolderSchema.ParentFolderId, FolderSchema.ExtendedProperties)); // Create appointment var appointment = new Appointment(service); appointment.Subject = "Impromptu Meeting"; appointment.Body = "Booked via Conference Room app."; appointment.Start = DateTime.Now; appointment.End = DateTime.Now.AddMinutes(request.BookMinutes); appointment.Location = responseMailboxInfo.DisplayName; appointment.Save(fid, SendInvitationsMode.SendToNone); // Verify saved Item item = Item.Bind(service, appointment.Id, new PropertySet(ItemSchema.Subject)); if (item == null) { response.ErrorMessage = "Error saving appointment to calendar."; return response; } else { response.AppointmentId = appointment.Id; response.Success = true; } } catch (Exception e) { response.ErrorMessage = e.ToString(); return response; } return response; }
public static void Subscribe(Node doclibrary, ExchangeService service) { if (service == null) return; var address = doclibrary["ListEmail"] as string; if (string.IsNullOrEmpty(address)) return; var mailbox = new Mailbox(address); var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox); var servicePath = string.Format(Configuration.PushNotificationServicePath, doclibrary.Path); var watermark = ExchangeHelper.GetWaterMark(doclibrary); var ps = service.SubscribeToPushNotifications(new List<FolderId> { folderId }, new Uri(servicePath), Configuration.StatusPollingIntervalInMinutes, watermark, EventType.NewMail); var loginfo = string.Concat(" - Path:",doclibrary.Path, ", Email:", address, ", Watermark:", watermark, ", SubscriptionId:", ps.Id); Logger.WriteInformation("Exchange subscription" + loginfo, ExchangeHelper.ExchangeLogCategory); // persist subscription id to doclib, so that multiple subscriptions are handled correctly var user = User.Current; try { AccessProvider.Current.SetCurrentUser(User.Administrator); var retryCount = 3; while (retryCount > 0) { try { doclibrary["ExchangeSubscriptionId"] = ps.Id; doclibrary.Save(); break; } catch (NodeIsOutOfDateException) { retryCount--; doclibrary = Node.LoadNode(doclibrary.Id); } } } finally { AccessProvider.Current.SetCurrentUser(user); } }
/// <summary> /// Initializes a new instance of the <see cref="FolderId"/> class. Use this constructor /// to link this FolderId to a well known folder (e.g. Inbox, Calendar or Contacts) in a /// specific mailbox. /// </summary> /// <param name="folderName">The folder name used to initialize the FolderId.</param> /// <param name="mailbox">The mailbox used to initialize the FolderId.</param> public FolderId(WellKnownFolderName folderName, Mailbox mailbox) : this(folderName) { this.mailbox = mailbox; }
/// <summary> /// Method is used for setting, updating and deleting delegate. /// </summary> /// <param name="xewsDelegate">Delegate object for manipulation.</param> /// <param name="delegateAction">Action on delegate (Add, Update, Delete).</param> internal void SetDelegate(XEwsDelegate xewsDelegate, DelegateAction delegateAction) { ExchangeService ewsSession = this.GetSessionVariable(); this.ValidateEmailAddress(xewsDelegate.DelegateUserId); string currentBindedMailbox = this.GetBindedMailbox(); DelegateUser delegateUser = new DelegateUser(xewsDelegate.DelegateUserId); Mailbox currentMailbox = new Mailbox(currentBindedMailbox); delegateUser.ReceiveCopiesOfMeetingMessages = xewsDelegate.ReceivesCopyOfMeeting; delegateUser.Permissions.CalendarFolderPermissionLevel = xewsDelegate.CalendarFolderPermission; delegateUser.Permissions.InboxFolderPermissionLevel = xewsDelegate.InboxFolderPermission; delegateUser.Permissions.ContactsFolderPermissionLevel = xewsDelegate.ContactFolderPermission; delegateUser.Permissions.TasksFolderPermissionLevel = xewsDelegate.TaskFolderPermission; switch (delegateAction) { case DelegateAction.Update: ewsSession.UpdateDelegates(currentMailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegateUser); break; case DelegateAction.Add: ewsSession.AddDelegates(currentMailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegateUser); break; case DelegateAction.Delete: ewsSession.RemoveDelegates(currentMailbox, delegateUser.UserId); break; } }
/// <summary> /// Methods is returning all delegate associated with currently binded user. /// </summary> /// <returns>List of delegates</returns> internal List<XEwsDelegate> GetDelegate() { ExchangeService ewsSession = this.GetSessionVariable(); List<XEwsDelegate> xewsDelegate = new List<XEwsDelegate>(); string currentBindedMailbox = this.GetBindedMailbox(); Mailbox currentMailbox = new Mailbox(currentBindedMailbox); DelegateInformation xewsDelegateInformation = ewsSession.GetDelegates(currentMailbox, true); foreach (DelegateUserResponse delegateResponse in xewsDelegateInformation.DelegateUserResponses) { if (delegateResponse.Result == ServiceResult.Success) { xewsDelegate.Add(new XEwsDelegate(delegateResponse)); } } return xewsDelegate; }
private string FreeRoom(string roomName) { // ToDo: error stategy to be implemented // log into Officee 365 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); //service.Credentials = new WebCredentials("*****@*****.**", "Passw0rd!"); service.Credentials = new WebCredentials("*****@*****.**", "Passw0rd!"); //service.Credentials = new WebCredentials("*****@*****.**", ""); service.UseDefaultCredentials = false; service.AutodiscoverUrl("*****@*****.**", RedirectionUrlValidationCallback); //EmailMessage email = new EmailMessage(service); //email.ToRecipients.Add("*****@*****.**"); //email.Subject = "HelloWorld"; //email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API."); //email.Send(); // GetRoomLists EmailAddressCollection roomGroup = service.GetRoomLists(); // GetRooms(roomGroup) Collection<EmailAddress> rooms = service.GetRooms(roomGroup[0]); string response = "No meeting room found"; //if the room.Address matchaes the one you are looking for then foreach (EmailAddress room in rooms) { if (room.Name == roomName) { Mailbox mailBox = new Mailbox(room.Address, "Mailbox"); //Mailbox mailBox = new Mailbox("*****@*****.**", "Mailbox"); // Create a FolderId instance of type WellKnownFolderName.Calendar and a new mailbox with the room's address and routing type FolderId folderID = new FolderId(WellKnownFolderName.Calendar, mailBox); // Create a CalendarView with from and to dates DateTime start = DateTime.Now.ToUniversalTime().AddHours(-8); DateTime end = DateTime.Now.ToUniversalTime().AddHours(5); //end.AddHours(3); CalendarView calendarView = new CalendarView(start, end); // Call findAppointments on FolderId populating CalendarView FindItemsResults<Appointment> appointments = service.FindAppointments(folderID, calendarView); // Iterate the appointments if (appointments.Items.Count == 0) response = "The room is free"; else { DateTime appt = appointments.Items[0].Start; TimeSpan test = DateTime.Now.Subtract(appt); int t = (int)Math.Round(Convert.ToDecimal(test.TotalMinutes.ToString())); if (test.TotalMinutes < 0) response = "a meeting is booked at this time"; else response = "the room is free for " + t.ToString() + "minutes"; } Console.WriteLine(response); } } return response; }
private static webServiceData.Appointment searchAppointmentByFilter(SchedulingInfo schedulingInfo, webServiceData.ExchangeService service, string appointmentID) { RvLogger.DebugWrite("enter searchAppointmentByFilter=============="); List<webServiceData.SearchFilter> searchORFilterCollection = new List<webServiceData.SearchFilter>(); if (null != appointmentID) searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.Id, new webServiceData.ItemId(appointmentID))); else { searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.Subject, schedulingInfo.subject)); searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.From, schedulingInfo.delegatorEmailAddr)); searchORFilterCollection.Add(new webServiceData.SearchFilter.IsGreaterThan(webServiceData.EmailMessageSchema.LastModifiedTime, DateTime.UtcNow.AddHours(-25))); if (!string.IsNullOrEmpty(schedulingInfo.storeEntryId)) searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.StoreEntryId, schedulingInfo.storeEntryId)); if (!string.IsNullOrEmpty(schedulingInfo.conversationKey)) searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.ConversationId, schedulingInfo.conversationKey)); } RvLogger.DebugWrite("enter searchAppointmentByFilter==============1"); webServiceData.SearchFilter searchFilter = new webServiceData.SearchFilter.SearchFilterCollection(webServiceData.LogicalOperator.And, searchORFilterCollection.ToArray()); RvLogger.DebugWrite("enter searchAppointmentByFilter==============2 " + schedulingInfo.delegatorEmailAddr); webServiceData.Mailbox mailBox = new webServiceData.Mailbox(schedulingInfo.delegatorEmailAddr); RvLogger.DebugWrite("enter searchAppointmentByFilter==============3"); webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar, mailBox); //No need to set mail since the service already know it. //webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar); RvLogger.DebugWrite("enter searchAppointmentByFilter==============4"); webServiceData.FindItemsResults<webServiceData.Item> results = service.FindItems( folderID, searchFilter, new webServiceData.ItemView(100)); RvLogger.DebugWrite("enter searchAppointmentByFilter==============5"); RvLogger.DebugWrite("results searchAppointmentByFilter==============" + (null == results.Items ? "0" : "" + results.Items.Count)); foreach (webServiceData.Item item in results) { try { webServiceData.Appointment appointment = (webServiceData.Appointment)item; if (string.IsNullOrEmpty(schedulingInfo.location)) schedulingInfo.location = ""; if (string.IsNullOrEmpty(appointment.Location)) appointment.Location = ""; if (schedulingInfo.location == appointment.Location && schedulingInfo.startDate.ToUniversalTime().Equals(appointment.Start.ToUniversalTime()) && schedulingInfo.endDate.ToUniversalTime().Equals(appointment.End.ToUniversalTime())) { RvLogger.DebugWrite("lastModifiedTime1===================" + appointment.LastModifiedTime); return appointment; } } catch (ScopiaMeetingAddInException ex) { throw ex; } } return null; }
private static webServiceData.Appointment searchAppointment(SchedulingInfo schedulingInfo, webServiceData.ExchangeService service) { RvLogger.DebugWrite("enter searchAppointment=============="); webServiceData.Mailbox mailBox = new webServiceData.Mailbox(schedulingInfo.delegatorEmailAddr); webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar, mailBox); webServiceData.CalendarFolder folder = webServiceData.CalendarFolder.Bind(service, folderID); webServiceData.CalendarView view = new webServiceData.CalendarView(schedulingInfo.startDate, schedulingInfo.endDate); webServiceData.PropertySet propertySet = new webServiceData.PropertySet(webServiceData.BasePropertySet.FirstClassProperties); view.PropertySet = propertySet; webServiceData.FindItemsResults<webServiceData.Appointment> results = folder.FindAppointments(view); RvLogger.DebugWrite("results==============" + (null == results.Items ? "0" : "" + results.Items.Count)); foreach (webServiceData.Item item in results) { try { webServiceData.Appointment appointment = (webServiceData.Appointment)item; if (string.IsNullOrEmpty(schedulingInfo.location)) schedulingInfo.location = ""; if (string.IsNullOrEmpty(appointment.Location)) appointment.Location = ""; if (string.IsNullOrEmpty(schedulingInfo.subject)) schedulingInfo.subject = ""; if (string.IsNullOrEmpty(appointment.Subject)) appointment.Subject = ""; if (schedulingInfo.location == appointment.Location && appointment.Subject == schedulingInfo.subject && 0 == appointment.Start.ToUniversalTime().CompareTo(schedulingInfo.startDate.ToUniversalTime()) && 0 == appointment.End.ToUniversalTime().CompareTo(schedulingInfo.endDate.ToUniversalTime())) { return appointment; } } catch (ScopiaMeetingAddInException ex) { throw ex; } } return null; }
public static FindItemsResults<Item> GetItems(ExchangeService service, string address) { var searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)); //var searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.Subject, "MyExchangeTest")); var mailbox = new Mailbox(address); var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox); var items = service.FindItems(folderId, searchFilter, new ItemView(5)); return items; }
public static List <IEmailMessage> GetIncomingEmails( string address, bool loadHtmlBody = false, CancellationToken cancellationToken = default) { Contract.Requires(!String.IsNullOrEmpty(address)); var settings = GetConnectionSettings(address); List <IEmailMessage> GetEmails() { var service = new EWS.ExchangeService(settings.Version) { Url = new Uri(settings.Url) }; if (settings.UseDefaultCredentials) { service.UseDefaultCredentials = true; } else { service.Credentials = new NetworkCredential(settings.UserName, settings.Password, settings.Domain); } var mailbox = new EWS.Mailbox(address); var inboxFolderId = new EWS.FolderId(EWS.WellKnownFolderName.Inbox, mailbox); var propertySet = new EWS.PropertySet(EWS.BasePropertySet.FirstClassProperties) { RequestedBodyType = EWS.BodyType.Text }; if (loadHtmlBody) { propertySet.Add(new EWS.ExtendedPropertyDefinition(ExtendedProperty_HtmlBody, EWS.MapiPropertyType.Binary)); } propertySet.Add(new EWS.ExtendedPropertyDefinition(ExtendedProperty_ConversationId, EWS.MapiPropertyType.Binary)); var view = new EWS.ItemView(100) { OrderBy = { { EWS.ItemSchema.DateTimeReceived, EWS.SortDirection.Ascending } }, PropertySet = propertySet }; var emails = (from item in service.FindItems(inboxFolderId, view) let email = item as EWS.EmailMessage where email != null select email).ToList(); if (emails.Count > 0) { propertySet.Add(EWS.ItemSchema.MimeContent); service.LoadPropertiesForItems(emails, propertySet); } return(emails.ConvertAll(email => { if (email.ItemClass == "IPM.Note.SMIME") { using (var memoryStream = new MemoryStream(email.MimeContent.Content)) { memoryStream.Position = 0L; var pkcs7Mime = (ApplicationPkcs7Mime)MimeEntity.Load(memoryStream); CryptographyContext.Register(typeof(WindowsSecureMimeContext)); pkcs7Mime.Verify(out var mimeEntity); var multipart = (Multipart)mimeEntity; var body = multipart.OfType <TextPart>().FirstOrDefault()?.Text; var message = multipart.OfType <TnefPart>().FirstOrDefault()?.ConvertToMessage(); return new EmailMessage( email, body, message?.Attachments .OfType <MimePart>() .Select(mp => { memoryStream.SetLength(0L); using (var contentStream = mp.Content.Open()) { contentStream.CopyTo(memoryStream); } return new FileAttachment( mp.FileName, memoryStream.ToArray()); }) .ToArray()); } } else { return (IEmailMessage) new EmailMessage(email); } })); } var retries = 0; while (true) { try { return(GetEmails()); } catch when(retries < settings.Retries) { //await Task.Delay(settings.RetryDelay, cancellationToken); retries++; } } }
private List<MailItem> SearchSharedMailBoxes(ExchangeService service, ItemView view, SearchFilter.SearchFilterCollection searchFilters, MailSearchContainerNameList mailBoxNames, string mailDomain, string searchTerm) { var result = new List<MailItem>(); if (mailBoxNames == null || mailBoxNames.Count <= 0 ) return result; foreach (var mailBoxName in mailBoxNames) { try { var fullyQualifiedMailboxName = String.Format("{0}@{1}", mailBoxName, mailDomain); Mailbox mb = new Mailbox(fullyQualifiedMailboxName); FolderId fid1 = new FolderId(WellKnownFolderName.Inbox, mb); var rootFolder = Folder.Bind(service, fid1); var items = rootFolder.FindItems(view); service.LoadPropertiesForItems(items, new PropertySet { ItemSchema.Attachments, ItemSchema.HasAttachments }); var matches = service.FindItems(fid1, searchFilters, view); AddItems(service, matches, result, fullyQualifiedMailboxName, "InBox"); } catch (ServiceResponseException) { //Ignore this indicates the user has no access to the mail box. Debug.WriteLine(String.Format("Trouble accessing mailbox {0} assuming no access.", mailBoxName)); } } return result; }
public string AddCalendar(string strOppID) { SLXapi.Opportunity slxOpp = SLXapi.Opportunity.GetByID(strOppID); if ((int)SLXapi.Helpers.Events.EventTypes.PSLevelTwoTraining == slxOpp.TypeID) return AddLevel2Calendar(strOppID); string strEntryID = slxOpp.OutlookID; ExchangeService service = GetExchangeService(EMAIL, PWD); //service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "*****@*****.**"); var userMailbox = new Mailbox(CALENDAR_EMAIL); FolderId folderId = new FolderId(WellKnownFolderName.Calendar, userMailbox); //Folder calendarFolder = Folder.Bind(service, folderId); //var itemView = new ItemView(20); // page size //var userItems = service.FindItems(folderId, itemView); bool apptExists = false; // Verify that the appointment was created by using the appointment's item ID. Appointment appt = null; try { ItemId idObj = new ItemId(strEntryID); appt = Appointment.Bind(service, idObj, new PropertySet(AppointmentSchema.Id, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End)); if (appt.Id.UniqueId == strEntryID) apptExists = true; } catch (Exception) { } //get the trainers initials string trainerInitials = string.Empty; try { List<SLXapi.Opportunity_Trainers> oppT = SLXapi.Opportunity_Trainers.GetByOpportunityID(slxOpp.OpportunityID); //create the opp trainer initial string if (oppT.Count > 0) trainerInitials += "("; for (int i = 0; i < oppT.Count; ++i) { SLXapi.Contact contact = SLXapi.Contact.GetByID(oppT[i].contactid); if (contact != null) { string initials = contact.firstname[0].ToString().ToUpper() + contact.lastname[0].ToString().ToUpper(); trainerInitials += initials; if (i + 1 < oppT.Count) trainerInitials += ","; } } if (oppT.Count > 0) trainerInitials += ")"; } catch (System.Exception e) { return "There was an exception adding the trainer initials " + e.Message; } if (appt == null) appt = new Appointment(service); if (!apptExists) slxOpp.OutlookBodyText = "http://fogbugz.askpri.org/default.asp?" + slxOpp.FogBugzMainTicket; appt.Subject = slxOpp.Type + " - " + slxOpp.Location + " " + trainerInitials; appt.Body = slxOpp.OutlookBodyText; appt.Location = slxOpp.Location; appt.Start = slxOpp.StartDate; appt.End = slxOpp.EndDate; appt.IsAllDayEvent = true; appt.IsReminderSet = false; appt.ReminderMinutesBeforeStart = 0; appt.Importance = Importance.Normal; appt.LegacyFreeBusyStatus = LegacyFreeBusyStatus.Free; try { if (apptExists) appt.Update(ConflictResolutionMode.AutoResolve); else appt.Save(folderId); } catch (COMException ex) { Console.WriteLine(ex.ToString()); return "There was an exception when saving appointment " + ex.Message; } Item item = Item.Bind(service, appt.Id, new PropertySet(ItemSchema.Subject)); Console.WriteLine("Retrieved Appointment: " + item.Subject + "\n"); //save the outlook appointment id to SLX Opportunity slxOpp.OutlookID = appt.Id.UniqueId; SLXapi.Opportunity.Save(slxOpp); return "Successfully Added to Outlook Calendar"; }
public GetCalendarItemsResponse Execute(GetCalendarItemsRequest request) { var response = new GetCalendarItemsResponse(); try { var service = ExchangeServiceConnector.GetService(request.MailboxEmail); //service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, request.MailboxEmail); service.HttpHeaders.Add("X-AnchorMailbox", request.MailboxEmail); // Initialize values for the start and end times, and the number of appointments to retrieve. DateTime startDate = DateTime.Today; DateTime endDate = startDate.AddDays(request.DaysToLoad); const int NUM_APPTS = 20; var mbx = new Mailbox(request.MailboxEmail); FolderId fid = new FolderId(WellKnownFolderName.Calendar, mbx); //FolderId fid = new FolderId(WellKnownFolderName.Calendar, request.MailboxEmail); //FolderId fid = new FolderId(WellKnownFolderName.Calendar); // Initialize the calendar folder object with only the folder ID. //CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()); CalendarFolder calendar = CalendarFolder.Bind(service, fid, new PropertySet(FolderSchema.ManagedFolderInformation, FolderSchema.ParentFolderId, FolderSchema.ExtendedProperties)); //CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet(FolderSchema.ManagedFolderInformation, FolderSchema.ParentFolderId, FolderSchema.ExtendedProperties)); // Set the start and end time and number of appointments to retrieve. CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS); // Limit the properties returned to the appointment's subject, start time, and end time. cView.PropertySet = new PropertySet( AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Organizer); // Retrieve a collection of appointments by using the calendar view. FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView); var items = new List<Models.AppointmentItem>(); foreach (var a in appointments) { //find appointments will only give basic properties. //in order to get more properties (such as BODY), we need to call EWS again //Appointment appointmentDetailed = Appointment.Bind(service, a.Id, new PropertySet(BasePropertySet.FirstClassProperties) { RequestedBodyType = BodyType.Text }); items.Add(new Models.AppointmentItem { Start = a.Start, End = a.End, Subject = a.Subject, Organizer = a.Organizer.Name }); } response.StartDate = startDate; response.EndDate = endDate; response.Appointments = items; response.Success = true; } catch (Exception e) { response.ErrorMessage = e.ToString(); } return response; }
/// <summary> /// Reads response elements from XML. /// </summary> /// <param name="reader"> /// The reader. /// </param> internal override void ReadElementsFromXml(EwsServiceXmlReader reader) { base.ReadElementsFromXml(reader); reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.MailTips); reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.RecipientAddress); reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Name); var email = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.EmailAddress); var routing = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.RoutingType); recipientAddress = new Mailbox(email, routing); reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.RecipientAddress); pendingMailTips = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PendingMailTips); reader.Read(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxFull)) { var mfTextValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxFull); mailboxFull = System.Convert.ToBoolean(mfTextValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.CustomMailTip)) { customMailTip = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.CustomMailTip); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.TotalMemberCount)) { var textValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.TotalMemberCount); totalMemberCount = System.Convert.ToInt32(textValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MaxMessageSize)) { var textValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MaxMessageSize); maxMessageSize = System.Convert.ToInt32(textValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.DeliveryRestricted)) { var restrictionTextValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DeliveryRestricted); deliveryRestricted = System.Convert.ToBoolean(restrictionTextValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsModerated)) { var moderationTextValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.IsModerated); isModerated = System.Convert.ToBoolean(moderationTextValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.InvalidRecipient)) { var invalidRecipientTextValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.InvalidRecipient); isInvalid = System.Convert.ToBoolean(invalidRecipientTextValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExternalMemberCount)) { var textValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ExternalMemberCount); externalMemberCount = System.Convert.ToInt32(textValue); reader.Read(); } if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.OutOfOffice)) { reader.Read(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ReplayBody)) { var msg = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Message); DateTime?startTime = null; DateTime?endTime = null; reader.Read(); reader.Read(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Duration)) { startTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.StartTime)); endTime = DateTime.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.EndTime)); reader.Read(); reader.Read(); } oof = new OutOfOfficeMessage(msg, startTime, endTime); reader.Read(); } } reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.MailTips); }