I'm currently working on creating a marketing email using the following request:
POST /marketing-emails/v1/emails/
constbody= {
name:'Test marketing email',
subject:'My email subject',
state:'AUTOMATED_DRAFT',
emailBody:`Hi You {{contact.firstname}}`,
templatePath: '@hubspot/email/dnd/welcome.html'
}
While the email is successfully created, I've encountered an issue where the email body remains the default template body instead of the custom body I included in the request.
Could you please advise on the necessary steps to resolve this issue?
I'd like to share my overall objective and see if you can assist me.
I want to create a sequence (or a workflow if sequence isn't possible) that, upon enrollment of a specific contact, triggers the automatic sending of a transactional email (or a marketing email if a transactional one isn't possible). The email should contain dynamic content, such as the contact name and a link that varies from one contact to another.
I intend to achieve all of this exclusively through the API, involving the following steps:
As per this (Legacy) HubSpot API doc, the "emailBody" parameter sets "the main content of the email within the 'main email body' module". As such, in your email template, you'll need to make sure you're using this "main email body" module. For example:
<!--
templateType: email
isAvailableForNewContent: true
-->
<!doctype html>
<html>
...
<body>
{% content_attribute "email_body" %}
The content you send via API as "emailBody" should appear here.
{% end_content_attribute %}
...
</body>
</html>
More information about the "Main email body" can be found here.
I hope this proves useful. Please let me know if you have any follow-up questions.
All the best,
Zach
--
Zach Klein HubSpot Integrations & App Developer Meanjin / Brisbane, Australia