locked
CRM 2011 beta Plug-in Retireve documentbody RRS feed

All replies

  • Hi,

    The code you have above 

    byte[] binary = Convert.FromBase64String(annot.Attributes["documentbody"].ToString());
    string content = UnicodeEncoding.UTF8.GetString(binary);

    is the correct way to convert the documentbody of an annotation record back to its string equivalent. 

    What type of file is the annotation? Converting a file attachment as above will only convert it back to the source stream format and would only really work with a basic text file, not an MS Word doc/docx for example.


    Michael Palmer
    xRMPalmer     @MJFPalmer     Rockstar365

    Friday, September 6, 2013 2:20 PM
  • Hi,

    I  need to read  MS Word doc/docx, file .

    what code modification need to be done. . .

    Tuesday, September 10, 2013 6:15 AM
  • Hi,

    Do you want to store the Word file to drive? Once you got the file content you can write to drive.

    if (annotationEntity.Attributes.Contains("filename"))
                    {
                        _fileName = Convert.ToString(annotationEntity.Attributes["filename"]);

                        // Get the File contant
                        byte[] fileContent = Convert.FromBase64String(annotationEntity.Attributes["documentbody"].ToString());

     using (System.IO.FileStream fs = System.IO.File.Create(File Path+_fileName ))
                            {
                                for (int i = 0; i < fileContent.Length; i++)
                                {
                                    fs.WriteByte(fileContent[i]);
                                }
                            }
                    }

    Thanks!

    Tuesday, September 10, 2013 6:34 AM
  • Hi,

    i need to read the doc / docx , as similar to  .txt file.

    is there any other method available, 

    Tuesday, September 10, 2013 7:30 AM
  • Is , there any method to read doc/ docx . As string .

    any idea, , ,

    Grateful for any help!!

    Tuesday, September 10, 2013 9:57 AM