Is it possible to send emails using Marketing Cloud API from Apex. The complete email will be dynamic with senderemail, recipientemail, body, subject being passed in API call and the API should just parse the details and send email to the end user.

Is this achievable through Marketing Cloud API

1 Answer 1


Short Answer:
Yes this is possible...but you probably shouldn't do it that way.

Long Answer:
I would highly recommend not going this way. Having the entire email passed inside of an API call is a lot of information that needs to be sent, received and processed for each email. With any decent type of volume/frequency, you are looking at potential for your messages to time out or error.

Plus any logging on the SFMC side (via a Triggered Send DE) would either become unweildy due to the HTML stored there, or be incomplete. You then run into how you would track things inside this email. SFMC would likely have issues with click tracking that you would need to address (as the content is brought in externally, which may pass after the link masking.) You also would not be able to differentiate any versions easily as it would all go through the same Triggered Send.

That being said, what you would need to do in order to accomplish it as you want is to create an email with AMPscript to have a dynamic body and subject/preheader and a Dynamic Sender Profile to allow you to change the from name/address.

Once this is all created, you would then combine these into a TriggeredSendDefinition that is what you would use in your API call. In the API call, you would need to pass each of these aspects of the email as separate parameters for the AMPscript in the Trigger to correctly receive and execute/output.

I would instead recommend that you have the content and data inside of SFMC and utilize the capabilities inside of there to build and send the message.

You must log in to answer this question.

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