Announcement

Collapse
No announcement yet.

Emailing some contacts in a small list view

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Emailing some contacts in a small list view

    Hello. I have the following structure: A "Job ad" entity with the description of the job, a "Job ad application" which is a list of applications sent by applicants, so the application entity has a foreign key in 'Contacts'. I have a small list view below the job ad with all the applications. I'd like to create a check box next to each application so the admin can select them and send an email to the contacts related to each selected application. is there an entity that already does this, so i can copy it? Or how would I go about adding the checkbox next to each application and then a button to open the email dialog? Thanks!

  • #2
    Hello
    https://www.espocrm.com/documentatio...de/mass-email/

    Comment


    • #3
      Is there an example in the Espo code? I am trying to do this from programming. I could create a template by hand, but how would I create, in code, the Target List and start sending?

      Comment


      • #4
        I did as follows, my last question is how to set the data for the email template? It seems that if I select 'Contact', I can only access the contact data. What I did was use a Formula to update the actual entity and copy the emailAddress over from Contact, and that's what I'm using. I haven't tested if it actually sends out the emails, I assume it will work once I configure SMTP.

        Code:
                $massEmail = $this->getEntityManager()->getEntity('MassEmail');
                $massEmail->set(array(
                    'name' => 'Mass email name',
                    'emailTemplateId' => '5a37ac4f76c163793'
                ));
                $this->getEntityManager()->saveEntity($massEmail);
                $queueItem = $this->getEntityManager()->getEntity('EmailQueueItem');
                $queueItem->set(array(
                    'status' => 'Pending',
                    'massEmailId' => $massEmail->get('id'),
                    'emailAddress' => $contact->get('emailAddress'),
                    'targetId' => $contact->get('id'),
                    'targetType' => 'Contact'
                ));
                $this->getEntityManager()->saveEntity($queueItem);

        Comment


        • #5
          application/Espo/Services/EmailTemplate.php
          if you need to send email to people (instances of Person, you can use Person.{fieldName} instead of Contact.{fieldName})

          Comment

          Working...
          X