You need to sign in to do that
Don't have an account?
Using SingleEmailMessage with a List ... how to construct the query and designate toAddresses?
Hi all,
I'm trying to pull a list of names from an object into a SingleEmailMessage send (about 3-5 recipients in each message, no more than 6 ever). The e-mail sends when someone updates a lesson plan, which is part of an apprenticeship.
Our objects are:
Contact = Stores the names and e-mail addresses
CT_Connector = Connects Contact with Apprenticeship
Apprenticeship = The name of the class
Lesson_Plan = A lesson within an apprenticeship
However, it seems that, to make this happen, we have to pull a list of names into a String[] . So far, here's what I have. I'm not receiving any Apex errors, and it compiles / uploads, but the query isn't working when I use the application... any thoughts?
Thanks!
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); List<String> toAddresses = new List<String>();for (CT_Connector__c u: [select Citizen_Teacher__r.Email from CT_Connector__c where Apprenticeships__r.Id = :lessonplan.id]) { toAddresses.add(u.Citizen_Teacher__r.Email); } mail.setToAddresses(toAddresses); // Specify the address used when the recipients reply to the email... etc