internal static SearchRequest CreateSearchRequest(string query, string collectionId, string conversationId, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
{
SearchRequest request = new SearchRequest
{
RequestData =
{
Items = new Request.SearchStore[]
{
new Request.SearchStore()
{
Name = SearchName.Mailbox.ToString(),
Query = new Request.queryType()
{
Items = new object[]
{
new Request.queryType()
{
Items = new object[]
{
collectionId,
query,
conversationId
},
ItemsElementName = new Request.ItemsChoiceType2[]
{
Request.ItemsChoiceType2.CollectionId,
Request.ItemsChoiceType2.FreeText,
Request.ItemsChoiceType2.ConversationId
}
}
},
ItemsElementName = new Request.ItemsChoiceType2[]
{
Request.ItemsChoiceType2.And
}
}
}
}
}
};
List<object> items = new List<object>();
List<Request.ItemsChoiceType6> itemsElementName = new List<Request.ItemsChoiceType6>();
if (bodyPreferences != null)
{
foreach (Request.BodyPreference bodyPreference in bodyPreferences)
{
items.Add(bodyPreference);
itemsElementName.Add(Request.ItemsChoiceType6.BodyPreference);
// Include the MIMESupport element in request to retrieve the MIME body
if (bodyPreference.Type == 4)
{
items.Add((byte)2);
itemsElementName.Add(Request.ItemsChoiceType6.MIMESupport);
}
}
}
if (bodyPartPreferences != null)
{
foreach (Request.BodyPartPreference bodyPartPreference in bodyPartPreferences)
{
items.Add(bodyPartPreference);
itemsElementName.Add(Request.ItemsChoiceType6.BodyPartPreference);
}
}
items.Add(string.Empty);
itemsElementName.Add(Request.ItemsChoiceType6.RebuildResults);
items.Add("0-9");
itemsElementName.Add(Request.ItemsChoiceType6.Range);
items.Add(string.Empty);
itemsElementName.Add(Request.ItemsChoiceType6.DeepTraversal);
request.RequestData.Items[0].Options = new Request.Options1()
{
ItemsElementName = itemsElementName.ToArray(),
Items = items.ToArray()
};
return request;
}