Microsoft.Protocols.TestSuites.MS_ASEMAIL.TestSuiteHelper.CreateItemOperationsFetchRequest C# (CSharp) Method

CreateItemOperationsFetchRequest() static private method

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:
static private CreateItemOperationsFetchRequest ( string collectionId, string serverId, Request bodyPreference, Request bodyPartPreference, Request schema ) : ItemOperationsRequest
collectionId string Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)
serverId string Specify a unique identifier that is assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)
bodyPreference Microsoft.Protocols.TestSuites.Common.Request Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)
bodyPartPreference Microsoft.Protocols.TestSuites.Common.Request Sets preference information related to the type and size of information for a message part (Refer to [MS-ASAIRS] 2.2.2.6)
schema Microsoft.Protocols.TestSuites.Common.Request Sets the schema information.
return ItemOperationsRequest
        internal static ItemOperationsRequest CreateItemOperationsFetchRequest(
            string collectionId,
            string serverId,
            Request.BodyPreference bodyPreference,
            Request.BodyPartPreference bodyPartPreference,
            Request.Schema schema)
        {
            // Set the ItemOperations:Fetch Options (See [MS-ASCMD] 2.2.3.115.2 Options)
            //  :: To get the whole content of the specified mail item, just ignore Fetch and Range element.
            //     See [MS-ASCMD] 2.2.3.145 Schema and 2.2.3.130.1 Range
            //  :: UserName, Password is not required by MS-ASEMAIl test case
            Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions();
            List<object> fetchOptionItems = new List<object>();
            List<Request.ItemsChoiceType5> fetchOptionItemsName = new List<Request.ItemsChoiceType5>();

            if (null != bodyPreference)
            {
                fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPreference);
                fetchOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to  [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    fetchOptionItemsName.Add(Request.ItemsChoiceType5.MIMESupport);

                    // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only
                    // (Refer to [MS-ASCMD] 2.2.3.100.1 MIMESupport)
                    fetchOptionItems.Add((byte)0x2);
                }
            }

            if (null != bodyPartPreference)
            {
                fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPartPreference);
                fetchOptionItems.Add(bodyPartPreference);
            }

            if (null != schema)
            {
                fetchOptionItemsName.Add(Request.ItemsChoiceType5.Schema);
                fetchOptionItems.Add(schema);
            }

            fetchOptions.Items = fetchOptionItems.ToArray();
            fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray();

            // *Only to fetch email item in mailbox* by using airsync:CollectionId & ServerId
            // So ignore LongId/LinkId/FileReference/RemoveRightsManagementProtection
            Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch()
            {
                CollectionId = collectionId,
                ServerId = serverId,
                Store = SearchName.Mailbox.ToString(),
                Options = fetchOptions
            };

            return Common.CreateItemOperationsRequest(new object[] { fetchElement });
        }