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
Michael MMichael M 

How to write SOQL query to fetch ListEmails sent from a Campaign?

Best Answer chosen by Michael M
AbhishekAbhishek (Salesforce Developers) 
SELECT Name, (SELECT Status,Contact.lastName FROM CampaignMembers where contactid != null), (SELECT Name, accountid FROM Opportunities__r where accountid= :inputAccountId) FROM Campaign where id in(SELECT CampaignId FROM Opportunity where accountid=:inputAccountId)


It will be something similar to the above soql
 
SELECT CampaignId,Id,Name,OwnerId,Status,Subject FROM ListEmail where campaignid=''

All Answers

AbhishekAbhishek (Salesforce Developers) 
SELECT Name, (SELECT Status,Contact.lastName FROM CampaignMembers where contactid != null), (SELECT Name, accountid FROM Opportunities__r where accountid= :inputAccountId) FROM Campaign where id in(SELECT CampaignId FROM Opportunity where accountid=:inputAccountId)


It will be something similar to the above soql
 
SELECT CampaignId,Id,Name,OwnerId,Status,Subject FROM ListEmail where campaignid=''
This was selected as the best answer
Michael MMichael M
Worked! Thank you!