# Transactional Email API

**URL:** <https://community.hubspot.com/t/transactional-email-api/93764>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [November 10, 2023, 12:48pm UTC](https://community.hubspot.com/t/transactional-email-api/93764 "2023-11-10T12:48:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TWolfe1](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@TWolfe1](https://community.hubspot.com/u/TWolfe1)\
**Post date:** [November 10, 2023, 12:48pm UTC](https://community.hubspot.com/t/transactional-email-api/93764/1 "2023-11-10T12:48:08Z")

</div>

When sending a SMTP email. How do I pass in the JSON payload and the template?

I can create my own custom Email body but I want to use a template in HubSpot and then populate the body dynamically.

I am using C# and have the following

MailMessage mm = new MailMessage();  
SmtpClient smtp = new SmtpClient();

mm.From = new MailAddress(“doNotreply@xx.ai”, “xx.ai daily report”, System.Text.Encoding.UTF8);  
mm.To.Add(new MailAddress(SubScriberEmail));  
mm.Subject = "Daily Foot Traffic Report " + myDateToShowInEmail;

[//mm.body](https://mm.body) =“Commented out to use a template”;

smtp.Host = “[smtp.hubapi.com](http://smtp.hubapi.com)”;

smtp.EnableSsl = true;  
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();  
NetworkCred.UserName = “fakeuser”;//  
NetworkCred.Password = “fakePassword”;// password  
// smtp.UseDefaultCredentials = ;  
smtp.Credentials = NetworkCred;  
//587 (for STARTTLS) or 465 (for TLS)  
smtp.Port = 587; //Gmail port for e-mail 465 or 587  
smtp.Send(mm);

I tried passing in a header, but that didn’t work.

mm.Headers.Add(“X-HubSpot-Template-Id”, “142328127660”); //didn’t work

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 13, 2023, 9:34pm UTC](https://community.hubspot.com/t/transactional-email-api/93764/2 "2023-11-13T21:34:44Z")

</div>

Hey, @TWolfe1 Thanks for your question. If you haven’t already, I’d suggest filing a support ticket and including your question but not the code (unless requested). This is because transactional email is a paid add-on. This part “When sending a SMTP email. How do I pass in the JSON payload and the template?

I can create my own custom Email body but I want to use a template in HubSpot and then populate the body dynamically.”

Looking at the documentation, I see a way to accomplish what you are describing using the [Single Send API](https://developers.hubspot.com/docs/api/marketing/transactional-emails#:~:text=the%20password%20field-,Single%2DSend%20API,-The%C2%A0Single). “The Single-Send API sends template emails created in the HubSpot email tool using a JSON-formatted `POST` request.”

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![TWolfe1](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@TWolfe1](https://community.hubspot.com/u/TWolfe1)\
**Post date:** [November 13, 2023, 9:37pm UTC](https://community.hubspot.com/t/transactional-email-api/93764/3 "2023-11-13T21:37:04Z")

</div>

Thanks. Correct we have paid for it. I figured out using the API but with SMTP. I do have support emails out regarding that as the variables for custom properties don’t seem to work like in their examples.
