function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harshi_PandeyHarshi_Pandey 

Get individual recipients' details from ListEmail in apex class

Hi,
I have a requirement to store individual recipient's Name, Email and Status from the ListEmail object. I want to store these details separately depending on the individual status (Sent or failed).
User-added image
Please help me here.
Suraj Tripathi 47Suraj Tripathi 47
Please find the solution.
List<Email_List__c> emailList=new List<Email_List__c>([Select Id, Name from Email_List__c where Name='sssssss']); 
	
	List<Recipient__c> reciepientList=new List<Recipient__c>([Select Id,Email_List__c ,Status,Name from Recipient__c where Email_List__c=:emailList[0].Id); 
	
	for(Recipient__c rp:reciepientList){
	if(rp.Status=='Failed'){
	//do something
	}else if(rp.Status=='Sent'){
	//do something
	}
	 
	 }

Please mark it as the best answer if it helps you .

Thank You

Suraj Tripathi 47Suraj Tripathi 47
Please find the solution.
List<Email_List__c> emailList=new List<Email_List__c>([Select Id, Name from Email_List__c where Name='sssssss']); 
	
	List<Recipient__c> reciepientList=new List<Recipient__c>([Select Id,Email_List__c ,Status,Name from Recipient__c where Email_List__c=:emailList[0].Id); 
	
	for(Recipient__c rp:reciepientList){
	if(rp.Status=='Failed'){
	//do something
	}else if(rp.Status=='Sent'){
	//do something
	}
	 
	 }

Please mark it as the best answer if it helps you .

Thank You

Harshi_PandeyHarshi_Pandey
@Suraj ListEmail is not a custom object. Its a standard object and have the emails when one clicks on 'Send list email' in contact or campaignmember object. I want to access the details of each recipients.
Rahul Gattani 10Rahul Gattani 10
Hi @Harshi_Pandey
Have you resolved this issue? if yes, then please provide the solution here. Thanks in advance.