/// <summary>
        /// Builds a ItemOperations request to fetch the whole content of a single mail item
        /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference
        /// In general, returns the XML formatted ItemOperations request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase">
        ///    <Fetch>
        ///       <Store>Mailbox</Store>
        ///       <airsync:CollectionId>5</airsync:CollectionId>
        ///       <airsync:ServerId>5:1</airsync:ServerId>
        ///       <Options>
        ///          <airsync:MIMESupport>2</airsync:MIMESupport>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>4</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>2</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///       </Options>
        ///    </Fetch>
        /// </ItemOperations>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param>
        /// <param name="serverIds">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param>
        /// <param name="schema">Sets the schema information</param>
        /// <returns>Returns the ItemOperationsRequest instance</returns>
        internal static ItemOperationsRequest CreateItemOperationsFetchRequest(string collectionId, List <string> serverIds, Request.Schema schema)
        {
            Request.ItemOperations itemOperations = new Request.ItemOperations();
            List <object>          items          = new List <object>();

            Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch();

            if (serverIds != null)
            {
                foreach (string item in serverIds)
                {
                    fetchElement.CollectionId = collectionId;
                    fetchElement.ServerId     = item;
                    items.Add(fetchElement);
                }
            }

            itemOperations.Items = items.ToArray();

            foreach (object item in itemOperations.Items)
            {
                Request.ItemOperationsFetch fetch = item as Request.ItemOperationsFetch;
                if (fetch != null)
                {
                    fetch.Store = SearchName.Mailbox.ToString();
                    Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions();

                    List <object> fetchOptionItems = new List <object>();
                    List <Request.ItemsChoiceType5> fetchOptionItemsName = new List <Request.ItemsChoiceType5>
                    {
                        Request.ItemsChoiceType5.BodyPreference,
                        Request.ItemsChoiceType5.Schema
                    };

                    fetchOptionItems.Add(
                        new Request.BodyPreference()
                    {
                        AllOrNone               = false,
                        AllOrNoneSpecified      = false,
                        TruncationSize          = 0,
                        TruncationSizeSpecified = false,
                        Preview          = 0,
                        PreviewSpecified = false,
                        Type             = 2,
                    });
                    fetchOptionItems.Add(schema);

                    fetchOptions.Items            = fetchOptionItems.ToArray();
                    fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray();
                    fetch.Options = fetchOptions;
                }
            }

            return(Common.CreateItemOperationsRequest(itemOperations.Items));
        }
Example #2
0
 /// <summary>
 /// Creates an ItemOperationsRequest instance using specified items
 /// </summary>
 /// <param name="items">Specified object items array</param>
 /// <returns>An ItemOperationsRequest instance</returns>
 public static ItemOperationsRequest CreateItemOperationsRequest(object[] items)
 {
     ItemOperationsRequest request = new ItemOperationsRequest();
     Request.ItemOperations requestData = new Request.ItemOperations { Items = items };
     request.RequestData = requestData;
     return request;
 }
        /// <summary>
        /// Builds a ItemOperations request to fetch the whole content of a single mail item
        /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference
        /// In general, returns the XML formatted ItemOperations request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase">
        ///    <Fetch>
        ///       <Store>Mailbox</Store>
        ///       <airsync:CollectionId>5</airsync:CollectionId>
        ///       <airsync:ServerId>5:1</airsync:ServerId>
        ///       <Options>
        ///          <airsync:MIMESupport>2</airsync:MIMESupport>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>4</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>2</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///       </Options>
        ///    </Fetch>
        /// </ItemOperations>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param>
        /// <param name="serverIds">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param>
        /// <param name="schema">Sets the schema information</param>
        /// <returns>Returns the ItemOperationsRequest instance</returns>
        internal static ItemOperationsRequest CreateItemOperationsFetchRequest(string collectionId, List<string> serverIds, Request.Schema schema)
        {
            Request.ItemOperations itemOperations = new Request.ItemOperations();
            List<object> items = new List<object>();

            Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch();

            if (serverIds != null)
            {
                foreach (string item in serverIds)
                {
                    fetchElement.CollectionId = collectionId;
                    fetchElement.ServerId = item;
                    items.Add(fetchElement);
                }
            }

            itemOperations.Items = items.ToArray();

            foreach (object item in itemOperations.Items)
            {
                Request.ItemOperationsFetch fetch = item as Request.ItemOperationsFetch;
                if (fetch != null)
                {
                    fetch.Store = SearchName.Mailbox.ToString();
                    Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions();

                    List<object> fetchOptionItems = new List<object>();
                    List<Request.ItemsChoiceType5> fetchOptionItemsName = new List<Request.ItemsChoiceType5>
                    {
                        Request.ItemsChoiceType5.BodyPreference,
                        Request.ItemsChoiceType5.Schema
                    };

                    fetchOptionItems.Add(
                        new Request.BodyPreference()
                        {
                            AllOrNone = false,
                            AllOrNoneSpecified = false,
                            TruncationSize = 0,
                            TruncationSizeSpecified = false,
                            Preview = 0,
                            PreviewSpecified = false,
                            Type = 2,
                        });
                    fetchOptionItems.Add(schema);

                    fetchOptions.Items = fetchOptionItems.ToArray();
                    fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray();
                    fetch.Options = fetchOptions;
                }
            }

            return Common.CreateItemOperationsRequest(itemOperations.Items);
        }
Example #4
0
 /// <summary>
 /// Creates an empty ItemOperationsRequest instance
 /// </summary>
 /// <returns>An ItemOperationsRequest instance</returns>
 public static ItemOperationsRequest CreateItemOperationsRequest()
 {
     ItemOperationsRequest request = new ItemOperationsRequest();
     Request.ItemOperations requestData = new Request.ItemOperations();
     request.RequestData = requestData;
     return request;
 }