2

I am looking to build functionality where I can completely build an email body as well as the list of recipients within apex then make a callout to Marketing cloud passing it all the data to then send the email. I am having issues finding documentation to help as I am trying to do this. Currently I am able to callout and authenticate into Marketing cloud and get a refresh token but I can't find documentation on what functions to do the next steps (sending an email). I found messageDefinitionSends but this seems to be to send something from a journey item which is not what I'm looking to do. I am basically looking to send an email using a salesforce report for the recipients as you can do in the UI of Marketing cloud but through the API.

Any help or suggestions are appreciated!

1 Answer 1

2

Yes, MessageDefinitionSends is the correct REST API method. Alternatively, you can use the SOAP API as documented here.

With either method you will need to firstly create a new Subscriber Profile Attribute in Email App > Subscribers > Profile Management. Ensure that the attribute name is prefixed with HTML__ (two underscores) as this overrides the max 4000 character length.

Next, you need to create an email and insert %%HTML__YourAttributeName%% where the HTML should appear in your email.

You can then create a Triggered Send Email using the email you just created from Email App > Interactions > Triggered Emails.

Start the Triggered Email and then use the Attribute in your request. For example:

Host: https://www.exacttargetapis.com
POST /messaging/v1/messageDefinitionSends/key:cust_key/send
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

{
    "From": {
        "Address": "[email protected]",
        "Name": "Simon Sausage"
    },
    "To": {
        "Address": "[email protected]",
        "SubscriberKey": "[email protected]",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "HTML__emailBody": "<body>hello world</body>"
            }
        }
    },
    "OPTIONS": {
        "RequestType": "ASYNC"
    }
}
13
  • Thanks Eliot, I will take a look into this today. How would this work if I was trying to send to multiple subscribers? List them as comma delimited or multiple calls? Commented Feb 6, 2017 at 15:29
  • Additionally I am having trouble locating the "entry event send definition". I am not sure how to locate it to find the ID or Cust_Key. Any help is appreciated. Commented Feb 6, 2017 at 16:44
  • Hi, you can't use this method to send to multiple subscribers. The cust_key value is the external key of the triggered email. You can view this at Email app > Interactions > Triggered Emails > External Key column (in the table). Commented Feb 6, 2017 at 19:27
  • Thanks!!I'm able to move past that now! Now onto solving my next errors of formatting the request how it wants haha. Commented Feb 8, 2017 at 4:30
  • Great, if I answered your question then please could you mark it as accepted for the benefit of others. Commented Feb 8, 2017 at 4:31

You must log in to answer this question.

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