function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ebikiebiki 

How to update the field in my custom object for bulk records

Hi all,
I'm new to these tasks, I want to send the email to the bulk records in my custom object and update the field after sending the email. Can any one help me over here.

Thanks in advance.
Regards,
ebiki.
rakesh.mupirirakesh.mupiri
How you are sending emails are you using any Batch Class/Schedule Class for this?
 
ebikiebiki
Hi rakesh,
I not sending i want ot now know how we can send the mass emails for the custom object records and update the filed.
 
Harish RamachandruniHarish Ramachandruni
public class sample 
{

public list<customobject__c> objlist {get;set;}


list<customobject__c> harish = new list<customobject__c> ();

public sample (){


objlist = [select id,name, Email__c from customobject__c limt 10  ]


}



public void send (){


for (customobject__c myContact : objlist ) {



    if (myContact.Email__c != null && myContact.name!= null) {
    


      Messaging.SingleEmailMessage mail =    new Messaging.SingleEmailMessage();
   
      // Step 2: Set list of people who should get the email

      List<String> sendTo = new List<String>();


      sendTo.add(myContact.Email__c);


      mail.setToAddresses(sendTo);
    
      // Step 3: Set who the email is sent from

      mail.setReplyTo('sirdavid@bankofnigeria.com');

      mail.setSenderDisplayName('Harish Rao Help Demo ');
    
      // (Optional) Set list of people who should be CC'ed

      List<String> ccTo = new List<String>();

      ccTo.add('business@Salesforce.com');

      mail.setCcAddresses(ccTo);

      // Step 4. Set email contents - you can use variables!


      mail.setSubject('URGENT BUSINESS PROPOSAL');
      String body = 'Dear ' + myContact.Name+ ', ';
      body += 'I confess this will come as a surprise to you.';
      body += 'I am John Alliston CEO of the Bank of Nigeria.';
      body += 'I write to request your cooperation in this ';
      body += 'urgent matter as I need a foreign partner ';
      body += 'in the assistance of transferring $47,110,000 ';
      body += 'to a US bank account. Please respond with ';
      body += 'your bank account # so I may deposit these funds.';
      mail.setHtmlBody(body);
    

      // Step 5. Add your email to the master list

      mails.add(mail);


 myContact.cooment__c = body ;

harish.add(myContact);

}

}

update harish ;

Messaging.sendEmail(mails);


}





}

Customobject__c  : custom object 


Comment__c custom filed ; text area 3000 

Email__c  custom field create in this object ; email data type .



Ask me any issue .



Regards ,
Harish.R.