Send a MMS Message from Apex

For sending MMS through a dev console or custom code, the following things are required:

  1. SMS History record is to be created with smagicinteract__Message_Type__c field as ‘MMS’
  2. The MMS Detail record is to be created with a lookup of the SMS History record that was created in the previous step 

Refer the below sample script to send MMS:

smagicinteract__smsMagic__c smsobj = new smagicinteract__smsMagic__c();
smsobj.smagicinteract__PhoneNumber__c = '919623197650';
smsobj.smagicinteract__Unformatted_Phone_Number__c = '919623197650';
smsobj.smagicinteract__SenderId__c = 'SMSSenderId';
smsobj.smagicinteract__disableSMSOnTrigger__c = 0;
smsobj.smagicinteract__SMSText__c = 'testSMS 2';
smsObj.smagicinteract__Message_Type__c = 'MMS';
smsObj.smagicinteract__MMS_Subject__c = 'Some random subject';
smsobj.smagicinteract__external_field__c = ApexAPI.generateUniqueKey();
insert smsObj;
smagicinteract__MMS_Detail__c mmsObj = new smagicinteract__MMS_Detail__c();
mmsObj.smagicinteract__MMS_Filename__c = 'Image';
mmsObj.smagicinteract__MMS_Url__c = ';
mmsObj.smagicinteract__SMS_History__c = smsObj.id;
insert mmsObj;

Was This Article Helpful?

6 Comments

Leave a comment

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

Important Announcement!

URGENT! Please register the 10-digit business phone number (e.g. 555-555-5555) that your organization uses to send texts to consumers in the U.S. Failure to register may cause heavy penalties and disruption to all your text messaging communications.