Send Bulk or Single SMS via Apex


You can send SMS via apex by creating a record at “SMS Bucket” Object.

Example : Sending SMS from contact update.

Trigger SendSMSOncontact on Contact (after update){

     List<rsplus__SMS_Bucket__c> smsForSending=new List<rsplus__SMS_Bucket__c>();

     for(contact c: trigger.new){

       rsplus__SMS_Bucket__c sms=new rsplus__SMS_Bucket__c();

       sms.rsplus__Number__c =c.MobilePhone; // required to send sms

       sms.rsplus__Sender_ID__c=’VluTxt’; // sender id is required to send sms

       sms.rsplus__Message__c =’Welcome to ValueText’; // message body is required to send sms

        OR       // You have to select rsplus__Message__c or rsplus__Template_ID__c

       sms.rsplus__Template_ID__c =’T0001’; // Template ID bust be name (API field of SMS Templates) of the Template

       sms.rsplus__Related_To__c=c.id; // Optional - id of the the record.

       smsForSending.add(sms);

     }// end of for

     Database.insert(smsForSending,false);

}// end of trigger