3

So, I'm doing a retrieve for all the Emails from our account, but the result also retrieves contents that were previously deleted. Does anyone know of a Email Object Property that I can use to filter only the ones that are visible on ET?

Here is my code, I'm filtering using Name and ModifiedDate:

APIObject[] results;
SimpleFilterPart spfl = new SimpleFilterPart();
SimpleFilterPart spfr = new SimpleFilterPart();
ComplexFilterPart cpfp = new ComplexFilterPart();

spfl.SimpleOperator = SimpleOperators.like;
spfl.Property = "Name";
spfl.Value = new String[] { "rgs" };

spfr.SimpleOperator = SimpleOperators.greaterThanOrEqual;
spfr.Property = "ModifiedDate";
spfr.DateValue = new DateTime[] { datePicked };

cpfp.LeftOperand = spfl;
cpfp.RightOperand = spfr;
cpfp.LogicalOperator = LogicalOperators.AND;

RetrieveRequest rr = new RetrieveRequest();
rr.ObjectType = "Email";
rr.Properties = new String[] { "ID", "PartnerKey", "CreatedDate", "ModifiedDate",
                "Client.ID", "Name", "PreHeader", "Folder", "CategoryID",
                "TextBody", "Subject", "IsActive", "IsHTMLPaste", "ClonedFromID",
                "Status", "EmailType", "CharacterSet", "HasDynamicSubjectLine",
                "ContentCheckStatus", "Client.PartnerClientKey", "ContentAreas",
                "CustomerKey", "HTMLBody", "IsApproved" } ;
rr.Filter = cpfp;

string status = ETclient.Retrieve(rr, out requestID, out results);



return results as APIObject[];

1 Answer 1

0

Add one more filter, set CategoryID (folderID) greaterThan 0, I think SFMC are moving deleted emails to a folder with ID = 0

SimpleFilterPart spfr3 = new SimpleFilterPart();
spfr3.SimpleOperator = SimpleOperators.greaterThan;
spfr3.Property = "CategoryID";
spfr3.Value = new string[] { "0" };

You may need two complex filter parts now, because you have three filters in total.

Edit:

I just realize that you are talking about email result contains deleted contentarea, not deleted emails. SFMC change deleted contentareas to categoryID=0. In Email RetrieveRequest, I couldn't find a way to filter deleted contentareas. When I add "ContentAreas.CategoryID" or "ContentArea.CategoryID" in filter part, it returns Error: The Filter Property 'ContentAreas.CategoryID' is not a retrievable property. I guess you have to loop through the contentareas collection returned in Email result, and manually filter any ContentArea has category=0

2
  • Unfortunately that's not the case. The "CategoryID" for each deleted email remains the same. The same goes for every other property apparently. I've got to the point where I compared every retrievable property between 4 different emails(2 deleted and 2 available) and there's no pattern in there that could lead me to anything. Even the property "IsActive", retrieves true for every single email in the account, deleted or not. I guess I'll need to be more inventive. Jul 26, 2016 at 3:18
  • I just realize that you are talking about email result contains deleted contentarea, not deleted emails. SFMC change deleted contentareas to categoryID=0. In Email RetrieveRequest, I couldn't find a way to filter deleted contentareas. When I add "ContentAreas.CategoryID" or "ContentArea.CategoryID" in filter part, it returns Error: The Filter Property 'ContentAreas.CategoryID' is not a retrievable property. I guess you have to loop through the contentareas collection returned in Email result, and manually filter any ContentArea has category=0
    – Bo Hu
    Jul 27, 2016 at 5:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .