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