According to ExactTarget:
There is a known issue with the MSCRM integrated accounts when using a Simple Filter Part on CategoryId via the API. You can use sfp.Property=”fkCategoryid’ and that should work. So you can above method or as a workaround, you can do the filtering in the client application (so your application once you retrieve all the data).
So far the theoretical information. Now the useful summary:
public ArrayList GetEmails(int folderId)
{
// Intialize variables
String requestID;
APIObject[] results;
// Create Filter
SimpleFilterPart sfp = new SimpleFilterPart();
sfp.Property = "fkCategoryID";
sfp.SimpleOperator = SimpleOperators.equals;
sfp.Value = new string[] { folderId.ToString() };
// Create RetrieveRequest
RetrieveRequest rr = new RetrieveRequest();
rr.QueryAllAccounts = true;
rr.QueryAllAccountsSpecified = true;
rr.ObjectType = "Email";
rr.Properties = new string[] { "Name", "ID", "CategoryID" };
rr.Filter = sfp;
// Execute RetrieveRequest
String status = _exactTarget.Retrieve(rr, out requestID, out results);
ArrayList alEmail = new ArrayList();
for (int i = 0; i < results.Length; i++)
{
Email email = (Email)results[i];
alEmail.Add(email);
}
return alEmail;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.