We are creating HTML Emails and I want to get the content of them by SSJS but the problem is their type is not "Email" or "ContentBlock", it is like in the middle of those. I can retrieve their IDs, CustomerKeys or Names when I treat them as "Assets" but not the content.

Can you help me find a way to retrieve the content of an HTML Email?

  • 1
    To confirm, are you looking to retrieve the HTML content for an individual Subscriber, that is, view the rendered HTML which includes the personalized content (from AMPscript or SSJS code) for that Subscriber? – Eliot Harper Aug 13 '18 at 9:29
  • No, I am trying to get HTML body of an HTML Email including Ampscript. – Selim Sevim Aug 13 '18 at 9:32
  • 1
    Are these in Content Builder or Classic? – Gortonington Aug 13 '18 at 12:49
  • Content Builder. "Email" type can be used for Classic view. – Selim Sevim Aug 13 '18 at 13:56

This is not something that can be achieved in the native SSJS, AMPScript functions nor by the SOAP API. You will need to utilize the REST API to get this. This is because Content Builder assets are stored elsewhere than classic, which is where the native functions and SOAP are aimed at.

I would utilize the 'GET Asset' REST Call.

Sample of call (using SSJS - assuming you gathered the auth Token already):

var authToken = "Bearer: " + accessToken;

var url = 'http://{{yourendpoint}}/asset/v1/content/assets?$filter=Name%20like%20'{{yourEmailName}}'';
var headerNames = ["Authorization"];
var headerValues = [authToken];
var response = HTTP.Get(url, headerNames, headerValues);

In the JSON you receive via the response, you will find the email content in items > views > html > content


    "items": [
            "views": {
                "html": {
                    "content": "{{yourHTMLContent}}"
  • Thanks a lot for your brief answer Gortonington. Could you please suggest an endpoint for S7 instance? I have tried "webservice.s7.exacttarget.com" but it didn't work. – Selim Sevim Aug 14 '18 at 11:23
  • @SelimSevim, that is the SOAP endpoint. Try using: https://www.exacttargetapis.com – Gortonington Aug 14 '18 at 15:47
  • I get this error: "Access Denied. URL: [www.exacttargetapis.com/asset/v1/content/assets?$filter=Name%20like%20'CO_DR_FLASH_DEAL_Q3_201808_KO_NA'] - from OMMCommon\r\n\r\n\r\n\r\n"}" – Selim Sevim Aug 19 '18 at 21:16
  • I would make sure your permissions are set appropriately, and then I would verify your authentication token – Gortonington Aug 19 '18 at 23:56
  • how can I check my permissions? – Selim Sevim Aug 20 '18 at 0:00

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.