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 *