Send Bulk SMS using APEX API

July 04, 2014

Send Bulk SMS

This API can be used to send Bulk SMS.

How to use Send Bulk SMS API ?

Assume that you are sending the bulk sms on Contact object You can follow the following steps :

  1. Create the List of type  smagicinteract__smsMagic__c.
  2. Iterate the contact list.
  3. Create the Object of smagicinteract__smsMagic__c.
  4. Now assign requried fields to the object.
  5. Make the callout to send the sms.
  6. Now call SOQL insert to insert the value into the salesforce org.

You can refer the following code for sending Bulk SMS.

List<smagicinteract__smsmagic__c> smsObjectList = new List<smagicinteract__smsmagic__c>();
List <Contact> conList; //List of contact populated from the visual force page or fetch from the database.
String templateText = 'test SMS by Screen Magic';
String senderId = 'smsMagic';
for(Contact contact :conList){
   smagicinteract__smsMagic__c smsObject = new smagicinteract__smsMagic__c();
   if(contact.MobilePhone != null){

     smsObject.smagicinteract__SenderId__c = senderId;
     smsObject.smagicinteract__PhoneNumber__c = contact.MobilePhone;
     smsObject.smagicinteract__Name__c = contact.Name;
     smsObject.smagicinteract__ObjectType__c = 'Contact';
     smsObject.smagicinteract__disableSMSOnTrigger__c = 1;
     smsObject.smagicinteract__external_field__c =
     smsObject.smagicinteract__SMSText__c = templateText;
 * Note : When you are using pushSMSCallout method to send the SMS
 *        please make sure that smagicinteract__disableSMSOnTrigger__c
 *        should have value as 1.
String response = smagicinteract.ApexAPI.pushSMSCallout(smsObjectList);

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>