I am trying to retrieve a specific email send that has gone out previously. I have been using the RetrieveRequest object in SSJS to attempt to access the "Email" object. It has been able to retrieve some emails but not the specific one I am looking for. I have attempted to narrow down the email using it's "Name" but it does not show up in the response.
Is there a specific date range or another aspect that is possible excluding a batch of emails from the call?
The code I am using at the moment is below. Thanks.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test - page</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script runat="server">
Platform.Load("Core","1");
var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "Email");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.ID");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.CustomerKey");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.Name");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.HTMLBody");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.TextBody");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.Subject");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.IsActive");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email.ContentAreas");
var sfp = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(sfp, "Property", "Name");
Platform.Function.SetObjectProperty(sfp, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(sfp, "Value", "[REMOVED]");
Platform.Function.SetObjectProperty(rr, "Filter", sfp);
var retrieveStatus = [0,0];
var emailResultSet = Platform.Function.InvokeRetrieve(rr, retrieveStatus);
Platform.Response.Write("Status: " + retrieveStatus[0] + "<br /><br />");
Platform.Response.Write("RequestID: " + retrieveStatus[1] + "<br /><br />");
for ( var c = 0 ; c < emailResultSet.length ; c++ )
{
Platform.Response.Write("CustomerKey " + emailResultSet[c].CustomerKey);
Platform.Response.Write(" > ");
Platform.Response.Write("ID " + emailResultSet[c].ID);
Platform.Response.Write(" > ");
Platform.Response.Write("ObjectID " + emailResultSet[c].ObjectID);
Platform.Response.Write(" > ");
Platform.Response.Write("HTMLBody " + emailResultSet[c].HTMLBody);
Platform.Response.Write(" > ");
Platform.Response.Write("TextBody " + emailResultSet[c].TextBody);
Platform.Response.Write(" > ");
Platform.Response.Write("ContentAreas " + emailResultSet[c].ContentAreas);
Platform.Response.Write(" - ");
Platform.Response.Write(emailResultSet[c].Name);
Platform.Response.Write("<br /><br />");
Platform.Response.Write("Subject " + emailResultSet[c].Subject);
Platform.Response.Write("<br /><br />");
}
</script>
</body>
</html>