/// <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); }