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);
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
 /// <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;
         }
     }
 }
Exemplo n.º 5
0
 /// <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);
        }
Exemplo n.º 7
0
 /// <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)
 {
 }
Exemplo n.º 8
0
 /// <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)
 {
 }
Exemplo n.º 11
0
 /// <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)
 {
 }
Exemplo n.º 12
0
 /// <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)
 {
 }
Exemplo n.º 13
0
 /// <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)
 {
 }
Exemplo n.º 14
0
 /// <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();
        }
Exemplo n.º 16
0
 /// <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)
 {
 }
Exemplo n.º 17
0
 /// <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)
 {
 }
Exemplo n.º 18
0
 /// <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)
 {
 }
Exemplo n.º 19
0
 /// <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)
 {
 }
Exemplo n.º 20
0
 /// <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)
 {
 }
Exemplo n.º 21
0
 /// <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)
 {
 }
Exemplo n.º 22
0
 /// <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)
 {
 }
Exemplo n.º 23
0
 /// <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)
 {
 }