• Rajesh M 77
  • 0 Points
  • Member since 2022

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
Actually I want to send the Automated birthday email notification whose birthdate is excactly equal to system. today() day and month. suppose i am having one custoom object named client and under that object there is custom field named Date Of Birth and email...and what i want is I want to schedule this every day and if the d.o.b filed data in exsisting record in client object day and month is equal to system.today() day and month then send the email to that all that records whose birthdate is today and also send email to that one more client whose email i had put it by hard coding.. i had used this logic.. but failed.. I checked on apex job it shows error email is null.... i hope you all understand... what I am trying to do..plz help
global class sendGreetingWishes implements Database.Batchable<sObject>
 string query;
 global Database.querylocator start(Database.BatchableContext bc)
  String query= 'SELECT Id, Name, email__c,birthday__c FROM stud__c';
  return Database.getQueryLocator(query);

global void execute(Database.BatchableContext bc, List<stud__c> scope)
 for(stud__c iteratorUser : scope)
   date thisdate=system.today();
   integer sysday=thisdate.day();
   integer sysmonth=thisdate.month();
   string dayandmonth=sysday+'/'+sysmonth;
   Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
   List<String> toAddresses = new List<String>();
   List<String> ccAddresses = new List<String>();
   email.setSubject('Happy Birthday. Have a blast — Birthday Reminder!');
   String message = 'Happy Birthday';
   Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});

 global void finish(Database.batchableContext bc)