Mass email leads without using Campaigns

How can we send a mass email to a few leads (for example, but same applies to contacts etc) using an Email Template with the Leads First Name (for example) embedded in the email template where the number to email does not merit a Campaign, Target List etc.

Currently selecting, say 6 Leads to Email from List View and then selecting Email from the Drop Down arrow results in one email to the 6 recipients. Then drag and drop the email addresses to BCC and obviously Email Template does not use the tokens as it is one email not 6 emails.

Hopefully there is a way to handle these small volume mail outs where Campaigns is overkill.

We know we can send 6 emails individually, but this is cumbersome.

If there is no option - fine - we just want to make sure we are not missing something obvious.

Thanks in advance

Greg Barrass

  • Hi Greg Barrass 

    You need to:

    • add a custom action into recordlist view of target modules (custom/modules/<Module>/clients/base/views/recordlist/recordlist.php) in order to render a new option on module selection list (right side of mass checkbox);
    • create the controller for this custom recordlist view of target module (custom/modules/<Module>/clients/base/views/recordlist/recordlist.js) in order to create the event behind clicked custom button;
    • create an endPoint which will mass send email to all selected records

    Find bellow some examples:

    custom/modules/<Module>/clients/base/views/recordlist/recordlist.php

    $viewdefs['ProductTemplates']['base']['view']['recordlist']['selection']['actions'][] = array(
       'name' => 'mass_integrate',
       'type' => 'button',
       'label' => 'LBL_MASS_INTEGRATE',
       'primary' => true,
       'events' => array(
          'click' => 'list:mass_integrate:fire',
       ),
       'acl_action' => 'massupdate',
    )

    custom/modules/<Module>/clients/base/views/recordlist/recordlist.js

    ({
       extendsFrom: 'RecordlistView',

       initialize: function(options) {
          this._super("initialize", [options]);
          this.context.on('list:mass_integrate:fire',this.mass_integrate,this);
       },

       mass_integrate:function(){
          var ids = _.map(this.context.get('mass_collection').models, function(selected_model){return selected_model.id});

          if(ids.length > 0){
             var data = {"product_id":ids};

             app.api.call('create', app.api.buildURL('ProductTemplates/MassIntegrate/'), data, {
                success: function(data) {
                   app.alert.show('integration-success', {
                      level: 'success',
                      messages: app.lang.getAppString('LBL_SUCCESS_INTEGRATION')
                   });
                },
             });
          }
       },
    })

    custom/modules/<Module>/clients/base/api/<someapi>Api.php

    class ProductsIntegrateApi extends SugarApi
    {
       public function registerApiRest()
       {
          return array(
             'MassIntegrate' => array(
                'reqType' => 'POST',
                'path' => array('ProductTemplates','MassIntegrate'),
                'pathVars' => array('', ''),
                'method' => 'integrate',
                'shortHelp' => '',
                'longHelp' => '',
             ),
          );
       }

       public function integrate($api, $args)
       {
          if (!is_array($args['product_id'])) {
             $args['product_id'] = (array) $args['product_id'];
          }

          foreach($args['product_id'] as $id){
             // send email
          }

          return array('status'=>'OK', 'message' => 'integration_finished');
       }
    }

    Remember to run QRR after saving the files.

    Kind regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Thanks very much Andre - will try it out and confirm result.