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)

How to convert MsWord Doc attachement of note to Plain text

(0) ShareShare
ReportReport
Posted on by 95

QueryExpression noteQuery = new QueryExpression

{

EntityName = "annotation",

ColumnSet = new ColumnSet(true),

Criteria = new FilterExpression

{

Conditions =

{

new ConditionExpression

{

AttributeName = "objectid",

Operator = ConditionOperator.Equal,

Values = { "92F7CEA6-7D7A-E611-81AC-001DD8B84ED2" }

},

}

}

};

EntityCollection notesCollection = service.RetrieveMultiple(noteQuery);

if (notesCollection.Entities.Count > 0)

{

foreach (Entity note in notesCollection.Entities)

{

if (note.Attributes.Contains("annotationid"))

{

Guid noteId = (Guid)note["annotationid"];

 }

if (note.Attributes.Contains("filename"))

{

String fileName = note["filename"].ToString();

 }

if (note.Attributes.Contains("documentbody"))

{

String file = note["documentbody"].ToString();

Console.WriteLine(file);

 }

}

}

I am getting documentbody as a base64 string how do I convert that to Plain text

byte[] theData = Convert.FromBase64String(file);

string content = System.Text.Encoding.UTF8.GetString(file);

this will not work as Attachement is wordDoc.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    You're not going to be able to do it easily. You'll need to get one of the open source Office readers and access the document that way, hoping to be able to pull the content out of the doc. It may not be perfect because the doc may have tables and other formatting that won't translate easily to plain text.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

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