I have emails attached in notes and attachments object.
When i try to read the body of Email i get Blob values suggest me ways to convert the blob into text.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
You can use
toString() of Blob class.
String myString = 'StringToBlob'; Blob myBlob = Blob.valueof(myString); System.assertEquals('StringToBlob', myBlob.toString());
Other option is by using
String.valueOf() of String class but not suggested as this returns useless string like
Blob[X] where X is the number of bytes in the blob.
There is one answer of sfdcfox which you might want to check before doing anything with blob. It says:
Blob.toString may result in an exception if the contents are not a Unicode String.
toString() with Try-Catch block. Check comments too for more details.