+ Start a Discussion
udayar_jayamudayar_jayam 

Messaging sendEmail Issue

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();
email.setToAddresses(toEmail);
email.setTargetObjectId(lstcountLead.id);
email.setTemplateId(templateId);
email.setSaveAsActivity(true);
lstMassEmails.add(email); 
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){
    maptargetToResult.put(lstMassEmails.get(i).getTargetObjectId(),sendEmailResult);    
    i++;
}
System.debug('!!!maptargetToResult'+maptargetToResult);(First Time)
!!!maptargetToResult{00Qp00000050eh9EAA=Messaging.SendEmailResult[getErrors=();isSuccess=true;]}
System.debug('!!!maptargetToResult'+maptargetToResult);(Second Time)
!!!maptargetToResult{00Qp00000050eh9EAA=Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError
[getMessage=The target object email address is currently marked as bounced.;getStatusCode=EMAIL_ADDRESS_BOUNCED;getTargetObjectId=00Qp00000050eh9EAA;]);
isSuccess=false;]}

 
Naveen KNNaveen KN
Hi Udayar, found a similar question in the community, Have a look @ https://developer.salesforce.com/forums/?id=9060G0000005WCyQAM 

Naveen