reminder emails

I like to write an apex class that sends a reminder email when a particular field is = today.

when I try to add this code I get errors. not sure why

Error: Compile Error: expecting right curly bracket, found 'EOF' at line 0 column -1

@IsTest
public class myRenewalDateNotify
{
 public static void sendRenewalNotify()
 {
  List<Account> aa=[SELECT Id,Name,Renewal_Date__c from Account WHERE Renewal_Date__c = Today];
    if (!aa.IsEmpty())
    {
    // send email notification    
        
        integer i = [Select COUNT() from Account where Renewal_Date__c = Today];
        
        system.debug=(i +' accounts are set for renewal today');    
       //String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + acct.Id;        
       //String[] toaddress = new String[]{};toaddress.add(emailaddress[i]);
       //Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       //mail.setToAddresses(toaddress);mail.setsubject(subject);
       
   // }
    }
  }

Open in new window

sullisnyc44Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

flow01Commented:
You have opening brackets at line 3,5,8 and closing on 20,21
Does uncommenting line 19 help ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sullisnyc44Author Commented:
Yes. it did.

however now I get another error when I uncomment the debug line:
Error: Compile Error: Variable does not exist: system.debug at line 13 column 8


@IsTest
public class myRenewalDateNotify{

  public static void sendRenewalNotify(string message){

      
    List<Account> accts=[SELECT Id,Name,Renewal_Date__c from Account WHERE Renewal_Date__c = Today];
  if (!accts.IsEmpty()){
        // send email notification    
        
        integer i = [Select COUNT() from Account where Renewal_Date__c = Today];
        
       system.debug=(i +' accounts are set for renewal today');    
    //String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + acct.Id;        
       //String[] toaddress = new String[]{};toaddress.add(emailaddress[i]);
       //Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       //mail.setToAddresses(toaddress);mail.setsubject(subject);
       
    }
  }
 }

Open in new window

sullisnyc44Author Commented:
I think this is what I would like to do.

i would like to query Accounts and see what is due for renewal today.

I would like to send one email message to myself and someone else that contains a list of those accounts with links to those accounts.

how do I build the body of the message?

@IsTest
public class myRenewalDateNotify{

  public static void sendRenewalNotify(string message){

      
    List<Account> accts=[SELECT Id,Name,Renewal_Date__c from Account WHERE Renewal_Date__c = Today];
  if (!accts.IsEmpty()){
        // send email notification    
        
       integer i = [Select COUNT() from Account where Renewal_Date__c = Today];
       system.debug=(i +' accounts are set for renewal today');    

        //String[] toaddress = new String[]{};toaddress.add(emailaddress[i]);    
        //Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();    
        //mail.setToAddresses(toaddress);mail.setsubject(subject);
       
         // loop through and build email body       
        for(Account a : accts){
        //String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + acct.Id;        

         }
        }
       }
     }

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Enterprise Software

From novice to tech pro — start learning today.