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
Karthik@TMCKarthik@TMC 

Help needed related to Attachments

I've got a word document as an attachment of a custom object, i can get it as blob by selecting the body of the attachment with a SOQL query : Attachment att = [ SELECT Body FROM Attachment WHERE PARENTID = '**' and ContentType='application/msword'] ; Blob b = att.body ; I tried to use the b.toString() function to have the content, but it didn't work.So is there any other way to convert the blob into a string that represent the text written in my word document. Even tried using EncodingUtil.base64Encode(att.body), but it didn't work. Thanks
crop1645crop1645

Ooh -- not so easy here

 

1. Word docs have binary values inside that won't convert to UTF-8 - that is why the toString() method fails

 

2. Unless you can get your sender to always send/upload text files, not .docx files, you are best off redesigning this application to not require inspection of the 'insides' of a Word file