Skip to content

Instantly share code, notes, and snippets.

@kellyjandrews
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellyjandrews/4fc2a00beec9cd022632 to your computer and use it in GitHub Desktop.
Save kellyjandrews/4fc2a00beec9cd022632 to your computer and use it in GitHub Desktop.
Message Definition Send Examples

In order to add the content directly as HTML - make sure the data extension contains "html_content" as a field. Set it to text, and leave the length blank.

Once you have that, then you can pass in the email file with very minimal content, or you can build out a full template based on each of your email types. Also note that you can split these up quite a bit - so your template can have much of the framework, and you can pass in a series of parameters in the REST payload that pull in specific content areas, so you don't have to code out your entire message. Multiple ways to approach this.

It all mostly depends on your data, how much you want to store, and how streamlined you want your process. Another item - I'm using email address as the subscriber key - but this can be any unique identifier.

%%html_content%%
This email was sent by: %%Member_Busname%%
%%Member_Addr%%
%%Member_City%%, %%Member_State%%, %%Member_PostalCode%%, %%Member_Country%%
<a href="%%profile_center_url%%" alias="Update Profile">Update Profile</a>
<custom name="opencounter" type="tracking">
/*
POST https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:{your external key}/send
Content-Type: application/json
Authorization: Bearer {{token}}
*/
{
"From": {
"Address": "name@email.com",
"Name": "Name"
},
"To": {
"Address": "name@email.com",
"SubscriberKey": "name@email.com",
"ContactAttributes": {
"SubscriberAttributes": {
"html_content": "<h1>Hello World!</h1>"
}
}
}
}
/*
POST https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:{your external key}/sendBatch
Content-Type: application/json
Authorization: Bearer {{token}}
*/
[
{
"From": {
"Address": "name@email.com",
"Name": "Name"
},
"To": {
"Address": "name1@email.com",
"SubscriberKey": "name1@email.com",
"ContactAttributes": {
"SubscriberAttributes": {
"html_content": "<h1>Hello World!</h1>"
}
}
}
},
{
"From": {
"Address": "name@email.com",
"Name": "Name"
},
"To": {
"Address": "name2@email.com",
"SubscriberKey": "name2@email.com",
"ContactAttributes": {
"SubscriberAttributes": {
"html_content": "<h1>Hello World!</h1>"
}
}
}
},
{
"From": {
"Address": "name@email.com",
"Name": "Name"
},
"To": {
"Address": "name3@email.com",
"SubscriberKey": "name3@email.com",
"ContactAttributes": {
"SubscriberAttributes": {
"html_content": "<h1>Hello World!</h1>"
}
}
}
}
]
{
"requestId": "3dab9046-2069-46cf-8268-7cca25591a4c",
"batchHasErrors": false,
"responses": [
{
"recipientSendId": "6278b28e-ba09-4156-af5c-e8f86dcea05c",
"hasErrors": false,
"messages": [
"Queued"
]
},
{
"recipientSendId": "d7a9a1f2-baa8-4b31-b8c5-4a740f78a597",
"hasErrors": false,
"messages": [
"Queued"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment