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
Shelly NyeinShelly Nyein 

Unable to send email in Visualforce page

Hi, 
I have select query as below. Based on the result, I want to send a single email with multiple records. How can I do that? I'm using Apex and visualforce page for this feature. If I use for loop, i can only get one record at a time and that is not what I want. 

public PageReference sendEmail(){
        system.debug('Status value is here '+statusValue);
        Records = [select Asset_Type__c, id, Active__c, Name, CPU_Model__c, Expiry_Date__c, Hostname__c, Location__c, Manufacturer__c, Model__c, PO_Number__c, Purchase_Date__c, Remark__c from IT_Inventory__c where Active__c =: statusValue];
        
//I want to send the whole list of result via email here. 

        return null;
    }
SouvikSomeSouvikSome

You can transform the query result into a JSON and you can send the JSON string as a EMAIL body.

You can transform SOQL response using either JSON.serializePretty(records) OR JSON.serialize(records) based on your solution.

Please mark my solution as Solved if it helps