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
pcmca_2007@yahoo.co.inpcmca_2007@yahoo.co.in 

Batch Apex Issue

Hi All,

          Can anybody tell me how bulkmail could be send with the batch apex.I want to send mail to all the opportunity

          whose StageName changes from one stage to some other stage.Can anybody suggest me the solution.

 

  With Regards

  Prabhash Mishra

nbknbk

Hi,

Try with below code

global class ApexScheduledClass Implements Schedulable

            {

                        global void execute(SchedulableContext sc)

                        {

                                   list<Object> obj = construct soql query [select id from object];

                                    if(obj.Size()>0)

                                   {

                                    sendmail();

                                   }

                        }

 

                        public void sendmail()

                        {

                                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

                                    string [] toaddress= New string[]{'testmail@abc.com'};

                                    email.setSubject('Testing Apex Scheduler-Subject');

                                    email.setPlainTextBody('Testing Apex Scheduler-Body');

                                    email.setToAddresses(toaddress);

                                    Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});

                        }

            }