<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to send a marketing email programmatically in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/839407#M66770</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/613940"&gt;@dmadusanka&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are just creating a contact and not associating it to an existing crm record I would remove the part of your code where you are handling hte association itself. i.e this part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$to1 = new PublicObjectId([
'id' =&amp;gt; '101'
]);
$associationSpec1 = new AssociationSpec([
'association_category' =&amp;gt; 'HUBSPOT_DEFINED',
'association_type_id' =&amp;gt; 2
]);
$publicAssociationsForObject1 = new PublicAssociationsForObject([
'to' =&amp;gt; $to1,
'types' =&amp;gt; [$associationSpec1]
]);
$simplePublicObjectInputForCreate = new SimplePublicObjectInputForCreate([
'properties' =&amp;gt; $properties1,
'associations' =&amp;gt; [$publicAssociationsForObject1],
]);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2023 08:07:18 GMT</pubDate>
    <dc:creator>coldrickjack</dc:creator>
    <dc:date>2023-08-24T08:07:18Z</dc:date>
    <item>
      <title>How to send a marketing email programmatically</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/837378#M66624</link>
      <description>&lt;P&gt;I want to create a marketing email template in HS and send it programmatically via my web app. And I need to set variables to make the email content dynamic.&amp;nbsp;&lt;SPAN&gt;Can someone suggest a solution for this, please? Highly appreciate your support.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 07:36:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/837378#M66624</guid>
      <dc:creator>dmadusanka</dc:creator>
      <dc:date>2023-08-21T07:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a marketing email programmatically</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/837431#M66632</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/613940"&gt;@dmadusanka&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whilst it is possible to send "&lt;A href="https://knowledge.hubspot.com/email/how-to-use-transactional-email-in-hubspot" target="_blank" rel="noopener"&gt;transactional&lt;/A&gt;" emails via the API (providing you've purchased the transactional email add-on) the same does not exist for "marketing" emails.&amp;nbsp; At present there is no method of sending marketing emails via the API with HubSpot. They must be sent manually to individual contacts/lists or automatically using workflows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One workaround to consider be to programmatically &lt;A href="https://legacydocs.hubspot.com/docs/methods/workflows/add_contact" target="_blank" rel="noopener"&gt;enroll a contact into a workflow&lt;/A&gt; and ensure the workflow has a send email action within it. You would need to make sure that you are constantly updating the worklfow action to use the appropriate marketing email or set up separate workflows for each campaign.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 09:28:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/837431#M66632</guid>
      <dc:creator>coldrickjack</dc:creator>
      <dc:date>2023-08-21T09:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a marketing email programmatically</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/838705#M66726</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/426475"&gt;@coldrickjack&lt;/a&gt; Thank you so much for your&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;workaround. It seems to be a good solution. I will work on this and let you know the result.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 09:29:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/838705#M66726</guid>
      <dc:creator>dmadusanka</dc:creator>
      <dc:date>2023-08-23T09:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a marketing email programmatically</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/838739#M66728</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/426475"&gt;@coldrickjack&lt;/a&gt;&amp;nbsp;As you suggested, now I am going to create a contact using &lt;A href="https://developers.hubspot.com/docs/api/crm/contacts" target="_blank" rel="noopener"&gt;this&lt;/A&gt;. I created a private app and gave "&lt;SPAN&gt;crm.objects.contacts.write" scope. But when I call create contact API it returns "invalid from object type 0-1 for associations to be created. expected: 0-2","correlationId". Any idea what would be the issue here? The code block I used is given below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;use HubSpot\Factory;&lt;BR /&gt;use HubSpot\Client\Crm\Contacts\ApiException;&lt;BR /&gt;use HubSpot\Client\Crm\Contacts\Model\AssociationSpec;&lt;BR /&gt;use HubSpot\Client\Crm\Contacts\Model\PublicAssociationsForObject;&lt;BR /&gt;use HubSpot\Client\Crm\Contacts\Model\PublicObjectId;&lt;BR /&gt;use HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInputForCreate;&lt;/P&gt;&lt;P&gt;$client = Factory::createWithAccessToken('YOUR_ACCESS_TOKEN');&lt;/P&gt;&lt;P&gt;$properties1 = [&lt;BR /&gt;'company' =&amp;gt; 'Biglytics',&lt;BR /&gt;'email' =&amp;gt; 'bcooper@biglytics.net',&lt;BR /&gt;'firstname' =&amp;gt; 'Bryan',&lt;BR /&gt;'lastname' =&amp;gt; 'Cooper',&lt;BR /&gt;'phone' =&amp;gt; '(877) 929-0687',&lt;BR /&gt;'website' =&amp;gt; 'biglytics.net'&lt;BR /&gt;];&lt;BR /&gt;$to1 = new PublicObjectId([&lt;BR /&gt;'id' =&amp;gt; '101'&lt;BR /&gt;]);&lt;BR /&gt;$associationSpec1 = new AssociationSpec([&lt;BR /&gt;'association_category' =&amp;gt; 'HUBSPOT_DEFINED',&lt;BR /&gt;'association_type_id' =&amp;gt; 2&lt;BR /&gt;]);&lt;BR /&gt;$publicAssociationsForObject1 = new PublicAssociationsForObject([&lt;BR /&gt;'to' =&amp;gt; $to1,&lt;BR /&gt;'types' =&amp;gt; [$associationSpec1]&lt;BR /&gt;]);&lt;BR /&gt;$simplePublicObjectInputForCreate = new SimplePublicObjectInputForCreate([&lt;BR /&gt;'properties' =&amp;gt; $properties1,&lt;BR /&gt;'associations' =&amp;gt; [$publicAssociationsForObject1],&lt;BR /&gt;]);&lt;BR /&gt;try {&lt;BR /&gt;$apiResponse = $client-&amp;gt;crm()-&amp;gt;contacts()-&amp;gt;basicApi()-&amp;gt;create($simplePublicObjectInputForCreate);&lt;BR /&gt;var_dump($apiResponse);&lt;BR /&gt;} catch (ApiException $e) {&lt;BR /&gt;echo "Exception when calling basic_api-&amp;gt;create: ", $e-&amp;gt;getMessage();&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 10:24:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/838739#M66728</guid>
      <dc:creator>dmadusanka</dc:creator>
      <dc:date>2023-08-23T10:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a marketing email programmatically</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/839407#M66770</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/613940"&gt;@dmadusanka&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are just creating a contact and not associating it to an existing crm record I would remove the part of your code where you are handling hte association itself. i.e this part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$to1 = new PublicObjectId([
'id' =&amp;gt; '101'
]);
$associationSpec1 = new AssociationSpec([
'association_category' =&amp;gt; 'HUBSPOT_DEFINED',
'association_type_id' =&amp;gt; 2
]);
$publicAssociationsForObject1 = new PublicAssociationsForObject([
'to' =&amp;gt; $to1,
'types' =&amp;gt; [$associationSpec1]
]);
$simplePublicObjectInputForCreate = new SimplePublicObjectInputForCreate([
'properties' =&amp;gt; $properties1,
'associations' =&amp;gt; [$publicAssociationsForObject1],
]);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 08:07:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-send-a-marketing-email-programmatically/m-p/839407#M66770</guid>
      <dc:creator>coldrickjack</dc:creator>
      <dc:date>2023-08-24T08:07:18Z</dc:date>
    </item>
  </channel>
</rss>

