How to generate a Text file using apex in Salesforce?

Sample Code:

        Employee__c e = [SELECT Name from Employee__c WHERE Id = : eid];
       
        Attachment a = new Attachment();
        a.ParentId = eid;
        a.Name = e.Name + Date.Today();
        a.ContentType = 'text/plain';
        a.Body = Blob.valueOf(e.Name);
       
        insert a;

Cheers!!!

No comments:

Post a Comment