How to resolve this error - Invalid character in identifier: objProject_Contacts__c?
I am trying to write an Apex class that will send emails to my project contacts. Still, I do face one error. I am not sure what I am doing wrong because I am a beginner in Apex.
public class SendIMRMonthlyEmails { @InvocableMethod public static void invokeapex(listProjectContacts){ List contactIds = new List(); List emailList = new List(); EmailTemplate et=[Select id from EmailTemplate where name = :System.Label.Sent_IMR_Monthly_Email_Project_Contacts limit 1]; for(Project_Contacts__c objProject_Contacts__c:ProjectContacts){ contactIds.add(objProject_Contacts__c.Id); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTargetObjectId(objProject_Contacts__c.Id); mail.setSenderDisplayName('System Admin'); mail.setTemplateId(et.id); mail.setBccAddresses(new List {System.Label.Sent_IMR_Monthly_Email_BCC_Email}); emailList.add(mail); } Messaging.sendEmail(emailList); } }
You are receiving this error - Invalid character in identifier: objProject_Contacts__c because you are declaring a variable (in this case on for-loop) with invalid double underscore c (objProject_Contacts__c).
You should do something like projectContact.