CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Programmatically create a scheduled civimail email
Pages: [1]

Author Topic: Programmatically create a scheduled civimail email  (Read 1549 times)

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Programmatically create a scheduled civimail email
December 20, 2011, 10:35:22 am
This may be in the API docs but I can't find it.  I'm using Drupal (6 or 7 -- either one will do) and I want to programmatically schedule a CiviMail email. I don't want to use Drupal's events and triggers because their mail-sending functions are separate from CiviMail.  So using the Civi API, how can I programmatically create an email, using a pre-defined CiviMail template and filling in programmatically all the needed params?
Thanks.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Programmatically create a scheduled civimail email
December 20, 2011, 10:37:53 am
It would be great if you can explain your use case.

Kurund
Found this reply helpful? Support CiviCRM

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Re: Programmatically create a scheduled civimail email
December 20, 2011, 10:54:00 am
Here's my use case.  It requires scheduling two emails.
(I know cron and SQL so just assume I've got those running fine.)
1.  An event, say a party or show, is going to occur.  The event data can be a simple field in the database or it could be a full CiviEvent item or a CMS field. I'm flexible as to that.
2.  When the event is created on the system, two emails are automatically scheduled:
      a. Four weeks before the event, a reminder will be sent out to relevant contacts. (I can figure out which contacts are relevant.)
      b. Two weeks after the event, a follow-up message will be sent to the contacts.

I want my content admins to be able to create CiviMail templates for the emails ahead of time, and then my code would choose the appropriate template.


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Programmatically create a scheduled civimail email
December 20, 2011, 08:19:49 pm

You should be able to use this feature in 4.1, which is currently in alpha release:

http://wiki.civicrm.org/confluence/display/CRM/Scheduled+Reminders+for+Events

However we did not have the time/resources to integrate this with CiviMail. Would be great to add CiviMail integration in a future release via an MIH and/or a code contribution

Would be great if you can test this and see how it fits

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Re: Programmatically create a scheduled civimail email
December 21, 2011, 04:17:23 pm
Thank you!  I will  explore that and test.  If I have learnings to share I'll post them here.

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Re: Programmatically create a scheduled civimail email
December 29, 2011, 12:27:53 pm
I've been testing the scheduled reminders in 4.1 alpha2 and so far it's excellent.  I've noticed a couple of small error warnings but I'm not going to post them till I install the new beta and see if they're still there (mainly it was a directory permission issue on install -- saying the directory for sites/default/files was not writable). So thank you, great job, and I'll continue to test, report, and debug.   

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Programmatically create a scheduled civimail email

This forum was archived on 2017-11-26.