You need to sign in to do that
Don't have an account?
viktorV
Sending Mass Email
I'd like to create a scheduled mass email sending automatism.
My code is:
List<Lead> newLeads= [SELECT Id FROM Lead WHERE ... ]; List<Id> toAddresses = new List<Id>(); for (Lead l: newLeads){ toAddresses.add(l.Id); } Messaging.MassEmailMessage welcomeMail = new Messaging.MassEmailMessage(); welcomeMail_Italy.setTargetObjectIds(toAddresses); welcomeMail_Italy.setTemplateId(' ... '); welcomeMail_Italy.setReplyTo(' ... '); welcomeMail_Italy.setSenderDisplayName(' ... '); Messaging.sendEmail(new Messaging.MassEmailMessage[] { welcomeMail });
I get the next error for the last line:
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Can you help me pls?
Thanks
V
the template id was wrong
All Answers
'welcomeMail_Italy' in code equals 'welcomeMail'
the template id was wrong