Skip to main content
1 of 3

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 faced one error . I am not sure what I am doing wrong cause I am a beginner in apex.

public class SendIMRMonthlyEmails {

@InvocableMethod
public static void invokeapex(list<Project_Contacts__c>ProjectContacts){
    List<Id> contactIds = new List<Id>();
    List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
    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<String> {System.Label.Sent_IMR_Monthly_Email_BCC_Email});
            emailList.add(mail);
        
    }
    
    Messaging.sendEmail(emailList);
}

}