Link to home
Start Free TrialLog in
Avatar of sullisnyc44
sullisnyc44Flag for United States of America

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of flow01
flow01
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sullisnyc44

ASKER

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

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