I'm using a single email message to send an email. When we tried to sent an email with a wrong email address on newly created lead record. I'm getting message result success is true. But the same record I have tried to send an email in the second time, I'm getting message result success is false. Please advice on this.

List<Messaging.SingleEmailMessage> lstMassEmails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Map<Id,Messaging.SendEmailResult> maptargetToResult = new Map<Id,Messaging.SendEmailResult>();
List<Messaging.SendEmailResult> sendEmailResults = Messaging.sendEmail(lstMassEmails,false);
Integer i=0; 
for(Messaging.SendEmailResult sendEmailResult: sendEmailResults){
System.debug('!!!maptargetToResult'+maptargetToResult);(First Time)
System.debug('!!!maptargetToResult'+maptargetToResult);(Second Time)
[getMessage=The target object email address is currently marked as bounced.;getStatusCode=EMAIL_ADDRESS_BOUNCED;getTargetObjectId=00Qp00000050eh9EAA;]);
  • Have you read the message? Do you know what a bounced email is? – Nick Cook Jan 29 '19 at 4:47
  • If I send an email to an invalid email address, I know that it will get bounced. I should have got the error in my first attempt itself. But, for the first attempt, it returns success as true. When i repeat the same, im getting bounced error. Would like to know why this happens? – user10286 Jan 29 '19 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.