+ 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});

                        }

            }