Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Is there a way to bulk export the HTML or Text versions of emails sent?

stephenjwz
Level 3
Level 3

Hi

Wondering about doing text analysis of some emails vs their performance, but unsure how I might get their content out of campaign & into another tool to analyse at scale?

Thanks

1 Accepted Solution
david_au1
Correct answer by
Level 2
Level 2

Hi @Stephenjqz !

I've been trying to do this lately... i'm sure others can assist, but you can pull the HTML or Text content out using the Generic Query Editor (see screenshots attached) or using Deliveries->export fields using the same sort of criteria.   Not the most elegant but a good start for a one off export/download of HTML.

screenshot 2 - html code saving.jpg

screenshot 3 - html code saving.jpg

screenshot 1 - html code saving.jpg

I also have written some draft javascript code below to get the HTML filzesize in KB for deliveries (raw total size, includes all personalisation blocks for example so may not be the final size that a customer receives in their inbox) which you can take or leave below (i;m sure it can be written more elegantly).

-------

function getByteLen(normal_val)

{

    // Force string type

    normal_val = String(normal_val);

    // Split original string into array

    var normal_pieces = normal_val.split('');

    // Get length of original array

    var normal_length = normal_pieces.length;

    // Declare array for encoded normal array

    var encoded_pieces = new Array();

    // Declare array for individual byte pieces

    var byte_pieces = new Array();

    // Loop through normal pieces and convert to URL friendly format

    for(var i = 0; i <= normal_length; i++)

    {

        if(normal_pieces[i] && normal_pieces[i] != '')

        {

            encoded_pieces[i] = encodeURI(normal_pieces[i]);

        }

    }

    // Get length of encoded array

    var encoded_length = encoded_pieces.length;

    // Loop through encoded array

    // Scan individual items for a %

    // Split on % and add to byte array

    // If no % exists then add to byte array

    for(var i = 0; i <= encoded_length; i++)

    {

        if(encoded_pieces[i] && encoded_pieces[i] != '')

        {

            // % exists

            if(encoded_pieces[i].indexOf('%') != -1)

            {

                // Split on %

                var split_code = encoded_pieces[i].split('%');

                // Get length

                var split_length = split_code.length;

                // Loop through pieces

                for(var j = 0; j <= split_length; j++)

                {

                    if(split_code[j] && split_code[j] != '')

                    {

                        // Push to byte array

                        byte_pieces.push(split_code[j]);

                    }

                }

            }

            else

            {

                // No percent

                // Push to byte array

                byte_pieces.push(encoded_pieces[i]);

            }

        }

    }

    // Array length is the number of bytes in string

    var byte_length = byte_pieces.length;

    return byte_length;

}

var query = xtk.queryDef.create( 

  <queryDef schema="nms:delivery" operation="select">   

    <select>     

      <node expr="@id"/>

      <node expr="@label"/>

    </select> 

    <where>

      <condition bool-operator="AND">

        <condition expr="@id > 100000000"/>

        <condition expr="@id < 110000000"/>

      </condition>

    </where>

  </queryDef>)

 

 

var res = query.ExecuteQuery()

var i = 0;

for each (var delivery in res.delivery)

{   

  i++;

 

  var id = delivery.@id.toString();

 

  var content = nms.delivery.get(id).content.html.source;

/*  logInfo(delivery.@label.toString() + " - Size KB  : " + (getByteLen(content)/1024).toFixed())  */

  logInfo(delivery.@id.toString() + "|" + (getByteLen(content)/1024).toFixed())

 

  if(i > 10)

    break;

}

Cheers,
David

View solution in original post

5 Replies
Steven_TechMark
Level 2
Level 2

Hi,

You will be able to extract the HTML versions of the deliveries by going into the delivery itself and saving the contents as a HTML file by selecting the save button.

Could I confirm if you are wishing to investigate a correlation between the the volume of data in the email vs the deliverabilty? What parameters are you wishing to include in your analysis?

stephenjwz
Level 3
Level 3

Hi Steven

Sure - I was just wondering if there was a way to do it at scale rather than individually.

Exact detail of what we were going to do we haven't pinned down yet - we have some html processing options & some word/phrase extraction stuff we're looking to try out.

Cheers

david_au1
Correct answer by
Level 2
Level 2

Hi @Stephenjqz !

I've been trying to do this lately... i'm sure others can assist, but you can pull the HTML or Text content out using the Generic Query Editor (see screenshots attached) or using Deliveries->export fields using the same sort of criteria.   Not the most elegant but a good start for a one off export/download of HTML.

screenshot 2 - html code saving.jpg

screenshot 3 - html code saving.jpg

screenshot 1 - html code saving.jpg

I also have written some draft javascript code below to get the HTML filzesize in KB for deliveries (raw total size, includes all personalisation blocks for example so may not be the final size that a customer receives in their inbox) which you can take or leave below (i;m sure it can be written more elegantly).

-------

function getByteLen(normal_val)

{

    // Force string type

    normal_val = String(normal_val);

    // Split original string into array

    var normal_pieces = normal_val.split('');

    // Get length of original array

    var normal_length = normal_pieces.length;

    // Declare array for encoded normal array

    var encoded_pieces = new Array();

    // Declare array for individual byte pieces

    var byte_pieces = new Array();

    // Loop through normal pieces and convert to URL friendly format

    for(var i = 0; i <= normal_length; i++)

    {

        if(normal_pieces[i] && normal_pieces[i] != '')

        {

            encoded_pieces[i] = encodeURI(normal_pieces[i]);

        }

    }

    // Get length of encoded array

    var encoded_length = encoded_pieces.length;

    // Loop through encoded array

    // Scan individual items for a %

    // Split on % and add to byte array

    // If no % exists then add to byte array

    for(var i = 0; i <= encoded_length; i++)

    {

        if(encoded_pieces[i] && encoded_pieces[i] != '')

        {

            // % exists

            if(encoded_pieces[i].indexOf('%') != -1)

            {

                // Split on %

                var split_code = encoded_pieces[i].split('%');

                // Get length

                var split_length = split_code.length;

                // Loop through pieces

                for(var j = 0; j <= split_length; j++)

                {

                    if(split_code[j] && split_code[j] != '')

                    {

                        // Push to byte array

                        byte_pieces.push(split_code[j]);

                    }

                }

            }

            else

            {

                // No percent

                // Push to byte array

                byte_pieces.push(encoded_pieces[i]);

            }

        }

    }

    // Array length is the number of bytes in string

    var byte_length = byte_pieces.length;

    return byte_length;

}

var query = xtk.queryDef.create( 

  <queryDef schema="nms:delivery" operation="select">   

    <select>     

      <node expr="@id"/>

      <node expr="@label"/>

    </select> 

    <where>

      <condition bool-operator="AND">

        <condition expr="@id > 100000000"/>

        <condition expr="@id < 110000000"/>

      </condition>

    </where>

  </queryDef>)

 

 

var res = query.ExecuteQuery()

var i = 0;

for each (var delivery in res.delivery)

{   

  i++;

 

  var id = delivery.@id.toString();

 

  var content = nms.delivery.get(id).content.html.source;

/*  logInfo(delivery.@label.toString() + " - Size KB  : " + (getByteLen(content)/1024).toFixed())  */

  logInfo(delivery.@id.toString() + "|" + (getByteLen(content)/1024).toFixed())

 

  if(i > 10)

    break;

}

Cheers,
David

View solution in original post

stephenjwz
Level 3
Level 3

thanks david - exatly what I needed

kumar451
Level 2
Level 2

Hi David,

I can see in your post that we are able to pull the html content from deliveries.But is it actual email content or just template we are getting out of that html?

Because I have a requirement to pull out the email content sent to the customer from campaign,Is there any way to pull the actual email content from campaign?

Thanks