0

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>
  • Is this email in Content Builder? If so, you need to utilize the REST API associated with Content Builder in order to access them. The SOAP endpoints only direct towards emails in classic content. – Gortonington Sep 6 '19 at 19:52
  • @Gortonington Yes, the email is in Content Builder. Any assistance with docs or help with how to go about using the REST API in this instance would be appreciated. Thanks. – Quaser8000 Sep 9 '19 at 11:13
1

As it is in Content Buider, you will need to use the Content Builder REST API to gather this email.

For instance, use the simple filter endpoint: /asset/v1/content/assets?$filter=Name%20like%20'yourEmailName'

As a note, this would return all assets (not just emails) named 'yourEmailName' - so may need to further filter if you have names duplicated across other content.

The return is a json that contains all associated information with that email, including stringified HTML of the email.

|improve this answer|||||
  • Okay, thank you. I will give this a try. – Quaser8000 Sep 9 '19 at 15:50
  • Yes, the Content Builder REST API approach was the way to go. I have managed to get a response back. Thanks Gortonington . – Quaser8000 Sep 19 '19 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.