2

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.

3
  • 1
    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. Commented Sep 29, 2017 at 17:41
  • @AdamSpriggs I think we may have figured out a way of sorts... I'll share if it works
    – Randy Hall
    Commented Sep 29, 2017 at 17:43
  • @AdamSpriggs Would you say still we are in the same picture? Thanks.
    – mario ruiz
    Commented May 11, 2022 at 4:20

2 Answers 2

5

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 ]%%
1
  • is this approach still valid? Thanks.
    – mario ruiz
    Commented May 9, 2022 at 19:56
3

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": ""
            }
        ]
    }
}
3
  • Is this method still supposed to work in 2023? I tried this setup and got an "Internal Server Error". Commented Jan 15, 2023 at 18:56
  • @ArthurNoort unfortunately I haven't worked with it since this post was made. I am unsure if this answer will work any more
    – J Fishback
    Commented Jan 16, 2023 at 19:20
  • @ArthurNoort this still worked as of July 2024. You need to use Legacy ID though. Commented Nov 15 at 23:15

You must log in to answer this question.

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