/// <summary> /// Binds to an existing post item and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the post item.</param> /// <param name="id">The Id of the post item to bind to.</param> /// <returns>An PostItem instance representing the post item corresponding to the specified Id.</returns> public static new PostItem Bind(ExchangeService service, ItemId id) { return PostItem.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal override void InternalLoadFromXml(EwsServiceXmlReader reader) { base.InternalLoadFromXml(reader); this.itemId = new ItemId(); this.itemId.LoadFromXml(reader, reader.LocalName); reader.Read(); this.ParentFolderId = new FolderId(); this.ParentFolderId.LoadFromXml(reader, XmlElementNames.ParentFolderId); switch (this.EventType) { case EventType.Moved: case EventType.Copied: reader.Read(); this.oldItemId = new ItemId(); this.oldItemId.LoadFromXml(reader, reader.LocalName); reader.Read(); this.OldParentFolderId = new FolderId(); this.OldParentFolderId.LoadFromXml(reader, reader.LocalName); break; default: break; } }
/// <summary> /// Binds to an existing e-mail message and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the e-mail message.</param> /// <param name="id">The Id of the e-mail message to bind to.</param> /// <returns>An EmailMessage instance representing the e-mail message corresponding to the specified Id.</returns> public static new EmailMessage Bind(ExchangeService service, ItemId id) { return EmailMessage.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Binds to an existing task and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the task.</param> /// <param name="id">The Id of the task to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>A Task instance representing the task corresponding to the specified Id.</returns> public static new Task Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<Task>(id, propertySet); }
/// <summary> /// Binds to an existing contact and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the contact.</param> /// <param name="id">The Id of the contact to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>A Contact instance representing the contact corresponding to the specified Id.</returns> public static new Contact Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<Contact>(id, propertySet); }
/// <summary> /// Binds to an existing meeting request and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the meeting request.</param> /// <param name="id">The Id of the meeting request to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>A MeetingRequest instance representing the meeting request corresponding to the specified Id.</returns> public static new MeetingRequest Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<MeetingRequest>(id, propertySet); }
/// <summary> /// Binds to an existing meeting cancellation message and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the meeting cancellation message.</param> /// <param name="id">The Id of the meeting cancellation message to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>A MeetingCancellation instance representing the meeting cancellation message corresponding to the specified Id.</returns> public static new MeetingCancellation Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<MeetingCancellation>(id, propertySet); }
/// <summary> /// Binds to an existing contact and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the contact.</param> /// <param name="id">The Id of the contact to bind to.</param> /// <returns>A Contact instance representing the contact corresponding to the specified Id.</returns> public static new Contact Bind(ExchangeService service, ItemId id) { return Contact.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Binds to an existing e-mail message and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the e-mail message.</param> /// <param name="id">The Id of the e-mail message to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>An EmailMessage instance representing the e-mail message corresponding to the specified Id.</returns> public static new EmailMessage Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<EmailMessage>(id, propertySet); }
/// <summary> /// Binds to an existing item, whatever its actual type is, and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the item.</param> /// <param name="id">The Id of the item to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>An Item instance representing the item corresponding to the specified Id.</returns> public static Item Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<Item>(id, propertySet); }
/// <summary> /// Binds to an existing meeting cancellation message and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the meeting cancellation message.</param> /// <param name="id">The Id of the meeting cancellation message to bind to.</param> /// <returns>A MeetingCancellation instance representing the meeting cancellation message corresponding to the specified Id.</returns> public static new MeetingCancellation Bind(ExchangeService service, ItemId id) { return MeetingCancellation.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Binds to an existing Persona and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the Persona.</param> /// <param name="id">The Id of the Persona to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>A Persona instance representing the Persona corresponding to the specified Id.</returns> public static new Persona Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<Persona>(id, propertySet); }
/// <summary> /// Binds to an existing meeting request and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the meeting request.</param> /// <param name="id">The Id of the meeting request to bind to.</param> /// <returns>A MeetingRequest instance representing the meeting request corresponding to the specified Id.</returns> public static new MeetingRequest Bind(ExchangeService service, ItemId id) { return MeetingRequest.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Binds to an existing appointment and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="id">The Id of the appointment to bind to.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>An Appointment instance representing the appointment corresponding to the specified Id.</returns> public static new Appointment Bind( ExchangeService service, ItemId id, PropertySet propertySet) { return service.BindToItem<Appointment>(id, propertySet); }
/// <summary> /// Binds to an existing task and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the task.</param> /// <param name="id">The Id of the task to bind to.</param> /// <returns>A Task instance representing the task corresponding to the specified Id.</returns> public static new Task Bind(ExchangeService service, ItemId id) { return Task.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Initializes a new instance of ItemIdWrapper. /// </summary> /// <param name="itemId">The ItemId object providing the Id.</param> internal ItemIdWrapper(ItemId itemId) { EwsUtilities.Assert( itemId != null, "ItemIdWrapper.ctor", "itemId is null"); this.itemId = itemId; }
public void DeleteContact(ItemId id) { Console.WriteLine(id); SqlConnection connection = DBConnection(); using (connection) { SqlCommand cmd = new SqlCommand("DELETE FROM Contacts WHERE CONTACTID = @ID"); cmd.CommandType = CommandType.Text; cmd.Connection = connection; cmd.Parameters.AddWithValue("@ID", id.ToString()); cmd.ExecuteNonQuery(); } }
/// <summary> /// Calls a phone and reads a message to the person who picks up. /// </summary> /// <param name="itemId">The Id of the message to read.</param> /// <param name="dialString">The full dial string used to call the phone.</param> /// <returns>An object providing status for the phone call.</returns> public PhoneCall PlayOnPhone(ItemId itemId, string dialString) { EwsUtilities.ValidateParam(itemId, "itemId"); EwsUtilities.ValidateParam(dialString, "dialString"); PlayOnPhoneRequest request = new PlayOnPhoneRequest(service); request.DialString = dialString; request.ItemId = itemId; PlayOnPhoneResponse serviceResponse = request.Execute(); PhoneCall callInformation = new PhoneCall(service, serviceResponse.PhoneCallId); return callInformation; }
public static T SafeBindItem <T>(Exchange.ExchangeService service, Exchange.ItemId id) where T : Exchange.Item { T value = null; try { value = Exchange.Item.Bind(service, id) as T; } catch (Exchange.ServiceResponseException exception) { string message = exception.Message; if (message.Contains(AccessDeniedErrorMessage) || message.Contains(MailBoxNotFoundErrorMessage) || message.Contains(MailBoxNotFoundErrorMessageRu) || message.Contains(AccessDeniedErrorMessageRu)) { Log.ErrorFormat("[ExchangeUtility.SafeBindItem]: Error while loading item with Id: {0}", exception, id); } else if (IsNotProcessedErrorMessages(message)) { throw; } } return(value); }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.ItemId: this.itemId = new ItemId(); this.itemId.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.Start: this.start = reader.ReadElementValueAsDateTime().Value; return true; case XmlElementNames.End: this.end = reader.ReadElementValueAsDateTime().Value; return true; case XmlElementNames.OriginalStart: this.originalStart = reader.ReadElementValueAsDateTime().Value; return true; default: return false; } }
/// <summary> /// Get the MIME for the item and return MIME as a string. /// /// </summary> /// <param name="oItemId">ItemId of Item with the MimeContent to get</param> /// <param name="service">Exchagne service to use</param> /// <param name="TheMime">MIME string to set</param> public static void GetItemMime(ItemId oItemId, ExchangeService service, ref string TheMime) { DebugLog.WriteVerbose(String.Format("Getting item MIME." )); string MimeToReturn = string.Empty; try { PropertySet oMimePropertySet = new PropertySet(ItemSchema.MimeContent); //Appointment oItem = (Appointment)Item.Bind(service, oItemId, oMimePropertySet); Item oItem = Item.Bind(service, oItemId, oMimePropertySet); if (oItem.MimeContent == null) throw new ApplicationException("No MIME content to write"); else MimeToReturn = oItem.MimeContent.ToString(); } catch (Exception ex) { MimeToReturn = "Error getting MIME: \r\n" + ex.Message; } TheMime = MimeToReturn; DebugLog.WriteVerbose(String.Format("Finished item MIME.")); }
static void TryGetAttachment(ExchangeService es, ItemId iid) { EmailMessage message = EmailMessage.Bind(es, iid, new PropertySet(ItemSchema.Attachments)); foreach (Attachment attachment in message.Attachments) { if (attachment is FileAttachment) { FileAttachment fileAttachment = attachment as FileAttachment; var filePath = logDir + fileAttachment.Name; // Load the attachment into a file. // This call results in a GetAttachment call to EWS. fileAttachment.Load(filePath); Log("Zapisałem załącznik: " + fileAttachment.Name + " w lokalizacji: " + filePath); } } }
/// <summary> /// Load from xml /// </summary> /// <param name="reader">The reader</param> /// <returns>Non indexable item object</returns> internal static NonIndexableItem LoadFromXml(EwsServiceXmlReader reader) { NonIndexableItem result = null; if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail)) { ItemId itemId = null; ItemIndexError errorCode = ItemIndexError.None; string errorDescription = null; bool isPartiallyIndexed = false; bool isPermanentFailure = false; int attemptCount = 0; DateTime? lastAttemptTime = null; string additionalInfo = null; string sortValue = null; do { reader.Read(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ItemId)) { itemId = new ItemId(); itemId.ReadAttributesFromXml(reader); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ErrorDescription)) { errorDescription = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorDescription); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed)) { isPartiallyIndexed = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPermanentFailure)) { isPermanentFailure = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsPermanentFailure); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AttemptCount)) { attemptCount = reader.ReadElementValue<int>(XmlNamespace.Types, XmlElementNames.AttemptCount); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.LastAttemptTime)) { lastAttemptTime = reader.ReadElementValue<DateTime>(XmlNamespace.Types, XmlElementNames.LastAttemptTime); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AdditionalInfo)) { additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo); } else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SortValue)) { sortValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SortValue); } } while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail)); result = new NonIndexableItem { ItemId = itemId, ErrorCode = errorCode, ErrorDescription = errorDescription, IsPartiallyIndexed = isPartiallyIndexed, IsPermanentFailure = isPermanentFailure, AttemptCount = attemptCount, LastAttemptTime = lastAttemptTime, AdditionalInfo = additionalInfo, SortValue = sortValue, }; } return result; }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsServiceXmlReader reader) { EwsUtilities.Assert( reader != null, "UserConfiguration.LoadFromXml", "reader is null"); reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.UserConfiguration); reader.Read(); // Position at first property element do { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.UserConfigurationName: string responseName = reader.ReadAttributeValue(XmlAttributeNames.Name); EwsUtilities.Assert( string.Compare(this.name, responseName, StringComparison.Ordinal) == 0, "UserConfiguration.LoadFromXml", "UserConfigurationName does not match: Expected: " + this.name + " Name in response: " + responseName); reader.SkipCurrentElement(); break; case XmlElementNames.ItemId: this.itemId = new ItemId(); this.itemId.LoadFromXml(reader, XmlElementNames.ItemId); break; case XmlElementNames.Dictionary: this.dictionary.LoadFromXml(reader, XmlElementNames.Dictionary); break; case XmlElementNames.XmlData: this.xmlData = Convert.FromBase64String(reader.ReadElementValue()); break; case XmlElementNames.BinaryData: this.binaryData = Convert.FromBase64String(reader.ReadElementValue()); break; default: EwsUtilities.Assert( false, "UserConfiguration.LoadFromXml", "Xml element not supported: " + reader.LocalName); break; } } // If XmlData was loaded, read is skipped because GetXmlData positions the reader at the next property. reader.Read(); } while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.UserConfiguration)); }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.AssignCategories: this.assignCategories.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.CopyToFolder: reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId); this.copyToFolder = new FolderId(); this.copyToFolder.LoadFromXml(reader, XmlElementNames.FolderId); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.CopyToFolder); return true; case XmlElementNames.Delete: this.delete = reader.ReadElementValue<bool>(); return true; case XmlElementNames.ForwardAsAttachmentToRecipients: this.forwardAsAttachmentToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.ForwardToRecipients: this.forwardToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.MarkImportance: this.markImportance = reader.ReadElementValue<Importance>(); return true; case XmlElementNames.MarkAsRead: this.markAsRead = reader.ReadElementValue<bool>(); return true; case XmlElementNames.MoveToFolder: reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId); this.moveToFolder = new FolderId(); this.moveToFolder.LoadFromXml(reader, XmlElementNames.FolderId); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.MoveToFolder); return true; case XmlElementNames.PermanentDelete: this.permanentDelete = reader.ReadElementValue<bool>(); return true; case XmlElementNames.RedirectToRecipients: this.redirectToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.SendSMSAlertToRecipients: EmailAddressCollection smsRecipientCollection = new EmailAddressCollection(XmlElementNames.Address); smsRecipientCollection.LoadFromXml(reader, reader.LocalName); this.sendSMSAlertToRecipients = ConvertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection(smsRecipientCollection); return true; case XmlElementNames.ServerReplyWithMessage: this.serverReplyWithMessage = new ItemId(); this.serverReplyWithMessage.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.StopProcessingRules: this.stopProcessingRules = reader.ReadElementValue<bool>(); return true; default: return false; } }
/// <summary> /// Binds to the master appointment of a recurring series and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="occurrenceId">The Id of one of the occurrences in the series.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>An Appointment instance representing the master appointment of the recurring series to which the specified occurrence belongs.</returns> public static Appointment BindToRecurringMaster( ExchangeService service, ItemId occurrenceId, PropertySet propertySet) { RecurringAppointmentMasterId recurringMasterId = new RecurringAppointmentMasterId(occurrenceId.UniqueId); return Appointment.Bind( service, recurringMasterId, propertySet); }
/// <summary> /// Binds to an existing appointment and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="id">The Id of the appointment to bind to.</param> /// <returns>An Appointment instance representing the appointment corresponding to the specified Id.</returns> public static new Appointment Bind(ExchangeService service, ItemId id) { return Appointment.Bind( service, id, PropertySet.FirstClassProperties); }
/// <summary> /// Initializes properties. /// </summary> /// <param name="requestedProperties">The properties requested for this UserConfiguration.</param> /// <remarks> /// InitializeProperties is called in 3 cases: /// . Create new object: From the UserConfiguration constructor. /// . Bind to existing object: Again from the constructor. The constructor is called eventually by the GetUserConfiguration request. /// . Refresh properties: From the Load method. /// </remarks> private void InitializeProperties(UserConfigurationProperties requestedProperties) { this.itemId = null; this.dictionary = new UserConfigurationDictionary(); this.xmlData = null; this.binaryData = null; this.propertiesAvailableForAccess = requestedProperties; this.ResetIsDirty(); }
/// <summary> /// Binds to an occurence of an existing appointment and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="recurringMasterId">The Id of the recurring master that the index represents an occurrence of.</param> /// <param name="occurenceIndex">The index of the occurrence.</param> /// <returns>An Appointment instance representing the appointment occurence corresponding to the specified occurence index .</returns> public static Appointment BindToOccurrence( ExchangeService service, ItemId recurringMasterId, int occurenceIndex) { return Appointment.BindToOccurrence( service, recurringMasterId, occurenceIndex, PropertySet.FirstClassProperties); }
/// <summary> /// Binds to an occurence of an existing appointment and loads the specified set of properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="recurringMasterId">The Id of the recurring master that the index represents an occurrence of.</param> /// <param name="occurenceIndex">The index of the occurrence.</param> /// <param name="propertySet">The set of properties to load.</param> /// <returns>An Appointment instance representing the appointment occurence corresponding to the specified occurence index.</returns> public static Appointment BindToOccurrence( ExchangeService service, ItemId recurringMasterId, int occurenceIndex, PropertySet propertySet) { AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId(recurringMasterId.UniqueId, occurenceIndex); return Appointment.Bind( service, occurenceId, propertySet); }
/// <summary> /// Binds to the master appointment of a recurring series and loads its first class properties. /// Calling this method results in a call to EWS. /// </summary> /// <param name="service">The service to use to bind to the appointment.</param> /// <param name="occurrenceId">The Id of one of the occurrences in the series.</param> /// <returns>An Appointment instance representing the master appointment of the recurring series to which the specified occurrence belongs.</returns> public static Appointment BindToRecurringMaster(ExchangeService service, ItemId occurrenceId) { return Appointment.BindToRecurringMaster( service, occurrenceId, PropertySet.FirstClassProperties); }
public Exchange.Contact GetFullContact(Exchange.ItemId itemId) { return(ExchangeUtility.SafeBindItem <Exchange.Contact>(Service, itemId)); }
/// <summary> /// Attempts to obtain a copy of this type by value identifier <paramref name="itemId"/>. /// If the value can not be obtained, the method returns <c>null</c>. /// </summary> /// <typeparam name="T">Type, inheritor <see cref="Exchange.Item"/>.</typeparam> /// <param name="service"><see cref="Exchange.ExchangeService"/> instance.</param> /// <param name="itemId">Represents the Id of an Exchange item.</param> /// <returns>An instance of this type, or <c>null</c>.</returns> public virtual T SafeBindItem <T>(Exchange.ExchangeService service, Exchange.ItemId itemId) where T : Exchange.Item { return(ExchangeUtility.SafeBindItem <T>(Service, itemId)); }