You need to sign in to do that
Don't have an account?
Harini
Read the attachment body from an apex class
Hi
I am trying to read the content of an attachment from an apex class.
Attachment att= [Select Id,a.ParentId, a.Name,a.body,a.ContentType From Attachment a where ParentId=:contactId limit 1];
System.debug('Attachment body : '+ att.body);
System.debug('Attachment body : '+ att.ContentType);
the attachment body content is displayed as :Blob[176680].
the body of the attachment is base64. I want to see the content of the body in plain english .
Any help is appreciated.
Thanks
When I use att.body.toString() , I get the error Blob is not a valid UTF-8 .Instead I have used EncodingUtil.base64Encode(att.body). Now I am not getting an error. But the string is not in readable form.
att.body is a base64 encoded. Any help to convert the body to readable form is appreciated.
Thanks