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
Nishi RanaNishi Rana 

Doc File Attachment

Hello EveryOne,

I have Doc File in Notes & Attachments.
I want to Fetch Body of doc file as a String in Apex Class.
as a body of Attachment return in Blob so how to get it as String ??
Ramesh DRamesh D
Just below code should do the trick. 
Blob myBlob = Your blob;
string myString= myBlob.toString();
Ajay K DubediAjay K Dubedi
Hi Nishi,

Use below get body of Notes & Attachments in blob:
Note notes = new Note;
notes = [SELECT Id, Title, ParentId, Body, CreatedDate FROM Note LIMIT 1];
String myString = notes.Body;
Blob myBlob = Blob.valueof(myString);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Ajay Dubedi