web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Read attachment body in dynamics crm using c#

(0) ShareShare
ReportReport
Posted on by

How to read text/string value from docx email-activity attachment  without downloading the file in dynamics crm.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
  • ganeshm Profile Picture
    on at

    thanks for reply,

    it doesnt work.

    for2.png

    In my requirement i have to read the text/string value directly from the encoded document without downloading or saving the file.

  • Community Member Profile Picture
    on at

    Thanks for sharing the reference, Mohd.

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    It looks like it is working, as you can see the content displayed.

    string fileName = (string)annotationFRI.Attributes["filename"];
    
                                
                                string noteText = (string)annotationFRI.Attributes["notetext"];
                                string documentBody = (string)annotationFRI.Attributes["documentbody"];
    
                                byte[] fileContent = Convert.FromBase64String(documentBody);
  • ganeshm Profile Picture
    on at

                         for3.png

    My .doc file attachment get encode in my 'activityattachment' . so using c# i can get the 'body' value .but using that value i cant get the text/string directly.

    i tired using,

    var encode= ent.Attributes["body"].ToString();
    byte[] byt = Convert.FromBase64String(encode);
    string decodedString = Encoding.UTF8.GetString(byt);

     in "decodedstring" i am getting the some junk values(pic in above post).

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Check this article, it should help you to find an answer - http://lmgtfy.com/?s=b&iie=1&q=read+docx+file+in+c%23

  • David Jennaway Profile Picture
    14,065 on at

    This probably aren't 'junk values' - this is the body of the document. Word documents need to be parsed by software that understands the document format, i.e. Microsoft Word

  • ganeshm Profile Picture
    on at

    thanks for the reply,

    That my problem without saving or creating a word document using that value, how to get the the string values present in the encoded files?Is there any way to get the string value ?

  • ganeshm Profile Picture
    on at

    so my scenario is like when i get a email attachment,i need to read text values from the attachment(using docx & excel types)

  • ashlega Profile Picture
    34,477 on at

    We can tell you how to use CRM SDK to correctly extract the contents of that attachment, but not necessarily how to parse a word document in your code. This might be a question you can get answered faster at stackoverflow (or C# forums)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans