Transactional Email API

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 =“Commented out to use a template”;

smtp.Host = “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

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. “The Single-Send API sends template emails created in the HubSpot email tool using a JSON-formatted POST request.”

Best,

Jaycee

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.