public EWSIncomingItemAttachment(ItemAttachment attachment) { _attachment = attachment; Logger.DebugFormat("Loading attachment"); var additionalProperties = new PropertySet { ItemSchema.MimeContent }; _attachment.Load(additionalProperties); Logger.DebugFormat("Attachment name is {0}", _attachment.Name); }
/// <summary> /// Initializes a new instance of the <see cref="Item"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal Item(ItemAttachment parentAttachment) : this(parentAttachment.Service) { EwsUtilities.Assert( parentAttachment != null, "Item.ctor", "parentAttachment is null"); this.parentAttachment = parentAttachment; }
/// <summary> /// Initializes a new instance of Appointment. /// </summary> /// <param name="parentAttachment">Parent attachment.</param> /// <param name="isNew">If true, attachment is new.</param> internal Appointment(ItemAttachment parentAttachment, bool isNew) : base(parentAttachment) { // If we're running against Exchange 2007, we need to explicitly preset // the StartTimeZone property since Exchange 2007 will otherwise scope // start and end to UTC. if (parentAttachment.Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1) { if (isNew) { this.StartTimeZone = parentAttachment.Service.TimeZone; } } }
/// <summary> /// Adds an item attachment to the collection /// </summary> /// <typeparam name="TItem">The type of the item to attach.</typeparam> /// <returns>An ItemAttachment instance.</returns> public ItemAttachment <TItem> AddItemAttachment <TItem>() where TItem : Item { if (typeof(TItem).GetCustomAttributes(typeof(AttachableAttribute), false).Length == 0) { throw new InvalidOperationException( string.Format( "Items of type {0} are not supported as attachments.", typeof(TItem).Name)); } ItemAttachment <TItem> itemAttachment = new ItemAttachment <TItem>(this.owner); itemAttachment.Item = (TItem)EwsUtilities.CreateItemFromItemClass(itemAttachment, typeof(TItem), true); this.InternalAdd(itemAttachment); return(itemAttachment); }
/// <summary> /// Initializes a new instance of the <see cref="MeetingRequest"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal MeetingRequest(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="Contact"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal Contact(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="MeetingCancellation"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal MeetingCancellation(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="MeetingMessage"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal MeetingMessage(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="PostItem"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal PostItem(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Saves this collection by creating new attachment and deleting removed ones. /// </summary> internal void Save() { List <Attachment> attachments = new List <Attachment>(); // Retrieve a list of attachments that have to be deleted. foreach (Attachment attachment in this.RemovedItems) { if (!attachment.IsNew) { attachments.Add(attachment); } } // If any, delete them by calling the DeleteAttachment web method. if (attachments.Count > 0) { this.InternalDeleteAttachments(attachments); } attachments.Clear(); // Retrieve a list of attachments that have to be created. foreach (Attachment attachment in this) { if (attachment.IsNew) { attachments.Add(attachment); } } // If there are any, create them by calling the CreateAttachment web method. if (attachments.Count > 0) { if (this.owner.IsAttachment) { this.InternalCreateAttachments(this.owner.ParentAttachment.Id, attachments); } else { this.InternalCreateAttachments(this.owner.Id.UniqueId, attachments); } } // Process all of the item attachments in this collection. foreach (Attachment attachment in this) { ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { // Make sure item was created/loaded before trying to create/delete sub-attachments if (itemAttachment.Item != null) { // Create/delete any sub-attachments itemAttachment.Item.Attachments.Save(); // Clear the item's change log itemAttachment.Item.ClearChangeLog(); } } } base.ClearChangeLog(); }
/// <summary> /// Initializes a new instance of the <see cref="EmailMessage"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal EmailMessage(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="Task"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal Task(ItemAttachment parentAttachment) : base(parentAttachment) { }
/// <summary> /// Initializes a new instance of the <see cref="MeetingResponse"/> class. /// </summary> /// <param name="parentAttachment">The parent attachment.</param> internal MeetingResponse(ItemAttachment parentAttachment) : base(parentAttachment) { }