Answers.Body: <p>There is a send email API in an extension that should be able to handle that? Not the automatic sending but you can trigger the API in whatever processing you do. Extension can be found here: <a href="https://github.com/CiviCooP/org.civicoop.emailapi" rel="nofollow">https://github.com/CiviCooP/org.civicoop.emailapi</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-21T14:15:45.157Z
Answers.Text: This extension is available in the [CiviCRM Extensions Directory](https://civicrm.org/extensions/e-mail-api) online, and it looks like it's new in 2015 and actively supported. (Thanks Jaap Jansma and CiviCooP!)  Is this correct that it's only confirmed compatible through Civi 4.5, and so it would not appear in a Civi 4.6.7 list of "native" extensions on the civicrm/admin/extensions page?
Answers.UserDisplayName: Daniel Ando Scholnick
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T06:53:30.020Z
Answers.Text: Yes, that is correct (and it is also updated by Ixiam if we are thanking :-)
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T07:01:09.573Z
Answers.LastActivityDate: 2015-05-18T07:01:09.573Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>I haven't tried the org.civicoop.emailapi extension, but I did give it a quick skim, and it didn't look like it would be suitable for the use case of an event registration confirmation email. I didn't see where it would accept params for the event ID or the participant ID, so while it might be able to send the appropriate template, much of the data wouldn't be populated.</p>
  
  <p>Instead I ended up using a core BAO. This is not recommended, because presumably the method is not intended to be a public interface and could change from one version to the next.</p>
  
  <p>Nevertheless, it was expedient. Here's some sample code for anyone else who may need to do this:</p>
  
  <pre><code>&lt;?php
  
  // your contact ID may come from elsewhere
  $cid = $form-&gt;getVar('_primary_volunteer_id');
  
  foreach ($form-&gt;_submitValues['field_added_by_buildform_hook'] as $eventId) {
    $participant = civicrm_api3('Participant', 'create', array(
      'contact_id' =&gt; $cid,
      'event_id' =&gt; $eventId,
      'role_id' =&gt; 'Attendee',
      'source' =&gt; 'My Customized Form',
    ));
  
    // elsewhere I have called civicrm_api3('Event', 'get', $params)
    // to populate $eventData
    $locBlock = civicrm_api3('LocBlock', 'getsingle', array(
      'id' =&gt; $eventData[$eventId]['loc_block_id'],
      'return' =&gt; 'all',
    ));
    // for some reason, the BAO expects 1-indexing rather than 0-indexing
    $locBlock['address'] = array(1 =&gt; $locBlock['address']);
  
    // Note: other stuff data can go into $mailParams, such
    // as fee information. It's not well-documented, and it
    // wasn't relevant to my use case, so I didn't bother.
    $mailParams = array(
      'event' =&gt; $eventData[$eventId],
      'location' =&gt; $locBlock,
    );
    CRM_Event_BAO_Event::sendMail($cid, $mailParams, $participant['id']);
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-19T12:13:28.753Z
Answers.Text: this is really handy - thanks - I was thinking that you could potentially add an option to the participant.create API send_confirmation to take care of sending the confirmation email.
Answers.UserDisplayName: michaelmcandrew
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-02T12:49:17.873Z
Answers.LastActivityDate: 2016-10-02T12:49:17.873Z
Answers.UserDisplayName: universalhandle
Answers.Body: <p>There is a <a href="https://github.com/systopia/de.systopia.eventmessages" rel="nofollow noreferrer">new extension called Event Messages</a> that an alternative way to send confirmation emails for CiviCRM Events.</p>
  <p>It creates an additional tab within CiviCRM Events that allows you to define different message templates to be sent based on conditions (including the participants status, role and preferred language). It will also allow you to suppress CiviCRM's regular emails.</p>
  <p>Probably that should cover the use case described here.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-06T21:24:06.000Z
Answers.Text: Thanks for this, turned out to be a great solution for my problem:
  https://civicrm.stackexchange.com/questions/44908/resend-all-registration-confirmation-emails-for-an-event
Answers.UserDisplayName: Lars SG
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-29T06:34:34.760Z
Answers.LastActivityDate: 2021-09-29T06:34:34.760Z
Answers.UserDisplayName: Fabian
Body: <p>We have a custom module that we use to do event registrations (non - paid), however i was wondering is there anyway through the API of being able to trigger CiviCRM sending a confirmation registration email when we submit the registration via API?</p>
  
Tags: <civievent><api>
Title: How to trigger a confirmation email when registering participants via API
ThreadText: # How to trigger a confirmation email when registering participants via API
  
  (Asked by: username_0 on 2015-05-18)
  
  We have a custom module that we use to do event registrations (non - paid), however i was wondering is there anyway through the API of being able to trigger CiviCRM sending a confirmation registration email when we submit the registration via API?
  
  **Tags:** civievent, api
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-05-18. Score: 4
  
  There is a send email API in an extension that should be able to handle that? Not the automatic sending but you can trigger the API in whatever processing you do. Extension can be found here: <https://github.com/CiviCooP/org.civicoop.emailapi>
  
  > **Comments:**
  > **username_2**: This extension is available in the [CiviCRM Extensions Directory](https://civicrm.org/extensions/e-mail-api) online, and it looks like it's new in 2015 and actively supported. (Thanks Jaap Jansma and CiviCooP!)  Is this correct that it's only confirmed compatible through Civi 4.5, and so it would not appear in a Civi 4.6.7 list of "native" extensions on the civicrm/admin/extensions page?  
  > **username_1**: Yes, that is correct (and it is also updated by Ixiam if we are thanking :-)  
  
  ---
  
  ### Answer by username_3 on 2016-10-02. Score: 3
  
  I haven't tried the org.civicoop.emailapi extension, but I did give it a quick skim, and it didn't look like it would be suitable for the use case of an event registration confirmation email. I didn't see where it would accept params for the event ID or the participant ID, so while it might be able to send the appropriate template, much of the data wouldn't be populated.
  Instead I ended up using a core BAO. This is not recommended, because presumably the method is not intended to be a public interface and could change from one version to the next.
  Nevertheless, it was expedient. Here's some sample code for anyone else who may need to do this:
  getVar('_primary_volunteer_id');
  
  foreach ($form->_submitValues['field_added_by_buildform_hook'] as $eventId) {
    $participant = civicrm_api3('Participant', 'create', array(
      'contact_id' => $cid,
      'event_id' => $eventId,
      'role_id' => 'Attendee',
      'source' => 'My Customized Form',
    ));
  
    // elsewhere I have called civicrm_api3('Event', 'get', $params)
    // to populate $eventData
    $locBlock = civicrm_api3('LocBlock', 'getsingle', array(
      'id' => $eventData[$eventId]['loc_block_id'],
      'return' => 'all',
    ));
    // for some reason, the BAO expects 1-indexing rather than 0-indexing
    $locBlock['address'] = array(1 => $locBlock['address']);
  
    // Note: other stuff data can go into $mailParams, such
    // as fee information. It's not well-documented, and it
    // wasn't relevant to my use case, so I didn't bother.
    $mailParams = array(
      'event' => $eventData[$eventId],
      'location' => $locBlock,
    );
    CRM_Event_BAO_Event::sendMail($cid, $mailParams, $participant['id']);
  }
  
  > **Comments:**
  > **username_4**: this is really handy - thanks - I was thinking that you could potentially add an option to the participant.create API send_confirmation to take care of sending the confirmation email.  
  
  ---
  
  ### Answer by username_5 on 2021-09-29. Score: 1
  
  There is a [new extension called Event Messages](https://github.com/systopia/de.systopia.eventmessages) that an alternative way to send confirmation emails for CiviCRM Events.
  
  It creates an additional tab within CiviCRM Events that allows you to define different message templates to be sent based on conditions (including the participants status, role and preferred language). It will also allow you to suppress CiviCRM's regular emails.
  
  Probably that should cover the use case described here.
  
  > **Comments:**
  > **username_6**: Thanks for this, turned out to be a great solution for my problem: https://civicrm.stackexchange.com/questions/44908/resend-all-registration-confirmation-emails-for-an-event  
  
  ---
  
  