1

I am sending emails via SFMC/ExactTarget to clients using SOAP. I store the returned request ID in a database.

Sometimes I specifically need to retrieve the completed HTML body from that request for local use. There are API calls for information about the email, but they do not appear to provide the body of the email.

I believe the body gets stored somewhere, as it is possible to provide a link to the browser view in the email that uses the subdomain we set up in SFMC as the root.

It would be acceptable to get the HTML via an API call with the request ID, or to get the preview url from an API call that we could then use to get the HTML.

  • Good luck. This the like the holy grail of SFMC engineers. All of us have tried to do it in some form, but haven't had much success. It could be that SF doesn't want this to be possible, since they sell archival services to financial institutions. It'd be nice for a lot of reasons. – Adam Spriggs Sep 29 '17 at 17:41
  • @AdamSpriggs I think we may have figured out a way of sorts... I'll share if it works – Randy Hall Sep 29 '17 at 17:43
2

I'm facing the very same challenge - and options suggested by SF was to use their archival service (or do a BCC on send).

One possible solution I've found -

  1. Create a Data Extension, with an unlimited text Field.
  2. Add Ampscript in your Template/Email to Log the HTML into the Data Extension
  3. Retrieve the HTML from the data extension using API (or flat file extract if needed)

In addition, using SQL & Automation you can combine the result from the data extension with the results of the _Sent and _JobID tables if desired.

%%[ 
IF _messagecontext == "SEND" AND jobid > 0 THEN
set @HTML = HTTPGet(view_email_url)
InsertDE("EmailHistory",
"JobID",jobid,
"SubscriberKey",_subscriberkey,
"EventDate",NOW(),
"HTML",@HTML
)
ENDIF
]%%

To get around the HTTPGet from executing/counting as an open, then also add :

%%[ IF _messagecontext == "SEND" OR _messagecontext == "VAWP" THEN ]%%

<custom name="opencounter" type="tracking">
%%[ ENDIF ]%%
2

I have been banging my head around with this too, but I believe I found a better answer.

Two caveats:

  1. Requires you are using content builder
  2. You'll need a sendable DE to test against. I found this by using the preview window within content builder and watching how they did it. Surprise Surprise they use their own API!

Assuming you have gotten the emails you want to render from

/asset/v1/content/assets/

You'll do a POST:

/guide/v1/emails/{asset_id}/dataExtension/{DE_id}/row/{any row number you want to use}/preview

This will return the following JSON structure:

{
    "message": {
        "links": {
            "self": {
                "href": ""
            }
        },
        "views": [
            {
                "contentType": "vnd.exacttarget.message.email.htmlBody",
                "content": ""
            },
            {
                "contentType": "vnd.exacttarget.message.email.subjectLine",
                "content": ""
            },
            {
                "contentType": "vnd.exacttarget.message.email.textBody",
                "content": ""
            },
            {
                "contentType": "application/vnd.etmc.email.View; kind=preheader",
                "content": ""
            }
        ]
    }
}

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.