sval1411
asked on
Extracting Text from a Notes Document.
Greetings,
Is there some way to extract the text from a Notes Document in VB.Net.
I am trying to mimic the File->Export functionality of the Notes Client.
Thanks in advance.
Is there some way to extract the text from a Notes Document in VB.Net.
I am trying to mimic the File->Export functionality of the Notes Client.
Thanks in advance.
Do you want to mimic it by accessing the Notes export functions, or do you wish to go straight at the raw data yourself to do the extraction? If you are doing the raw data route, do you need just the text (unformatted) or do you need formatted text (tables, fonts, color, style, non-textual elements)?
ASKER
Greetings,
Thanks for the responses.
When you do a File->Export and Save it as ACII text, it only exports the text from the the document. Say it was an email document, then it would export, the following fields:
From (sender)
To
CC
BCC
Body
(I guess these are the fields that are present in the "Memo" form)
The Body is exported as raw text, I dont believe the format elements like tables, fonts, color, etc. are exported.
I am able to extract all the metadata associated with a document (including the hidden fields - fields that start with a "$"). But when you use the Notes File->Export functionality, Not all fields get exported - only the fields that are visible to the user when the document is opened in the Notes Client.
I am hoping to do this without using "SendKeys".
Thanks in advance. Appreciate all the time and effort.
Thanks for the responses.
When you do a File->Export and Save it as ACII text, it only exports the text from the the document. Say it was an email document, then it would export, the following fields:
From (sender)
To
CC
BCC
Body
(I guess these are the fields that are present in the "Memo" form)
The Body is exported as raw text, I dont believe the format elements like tables, fonts, color, etc. are exported.
I am able to extract all the metadata associated with a document (including the hidden fields - fields that start with a "$"). But when you use the Notes File->Export functionality, Not all fields get exported - only the fields that are visible to the user when the document is opened in the Notes Client.
I am hoping to do this without using "SendKeys".
Thanks in advance. Appreciate all the time and effort.
ASKER
Greetings,
I found a work around to acheive "Text Extraction", but it does not completely mimic the File Export functionality of the Notes Client.
Here is what I have done:
1) Render the document to a Rich Text Item.
2) Attach that Rich Text Item to another, newly created document.
3) From the newly created Document - retrieve the text from that Rich Text Item.
4) Delete (Remove permanently) the newly created document.
Attached please find the code snippet.
I found a work around to acheive "Text Extraction", but it does not completely mimic the File Export functionality of the Notes Client.
Here is what I have done:
1) Render the document to a Rich Text Item.
2) Attach that Rich Text Item to another, newly created document.
3) From the newly created Document - retrieve the text from that Rich Text Item.
4) Delete (Remove permanently) the newly created document.
Attached please find the code snippet.
'notesDoc = Document whose text needs to be extracted / exported
'"renderedDoc" = Name of the Rich Text Item that the above notesDoc is going to be rendered to
'newNotesDoc = temp notes document that shall store the "renderedDoc"
'notesRTItem = temp notes rich text item that shall extract the text from the item named "renderedDoc" in the newNotesDoc
newNotesDoc = notesDatabase.CreateDocument() 'creating temp notes doc
newNotesDoc.CreateRichTextItem("renderedDoc")'creating rtitem named "renderedDoc"
notesDoc.RenderToRTItem(newNotesDoc.GetFirstItem("renderedDoc")) 'rendering the notesDoc
notesRTItem = newNotesDoc.GetFirstItem("renderedDoc") 'extracting the text from the rtitem named "renderedDoc"
MessageBox.Show(notesRTItem.GetFormattedText(True, 0))
newNotesDoc.Remove(True)
ASKER
Only one question that I had was,
with the above code, I am able to successfully extract all the text. but the format of the text that is extracted is a little different from File->Export (ASCII text) functionality.
This might not be too much of an issue, but it would be great if I can have the same formatting as the File->Export functionality.
Any suggestions on this are more than welcome.
Thanks.
with the above code, I am able to successfully extract all the text. but the format of the text that is extracted is a little different from File->Export (ASCII text) functionality.
This might not be too much of an issue, but it would be great if I can have the same formatting as the File->Export functionality.
Any suggestions on this are more than welcome.
Thanks.
just use:
Set body = notesDoc.getFirstItem("Body")
bodyText = body.getFormattedText(True,72)
'or body.getUnformattedText(), or change 72 to a different wrap, or change True to False to leave any tab as-is
ASKER
Thanks, I used that it does extract the text successfully, but the formating is not the same as Notes->File Export.
This code does help though.
This code does help though.
It should be very, very close
ASKER
yes it is,
it does get all the necessary text form the doc.
Do you know how the File->Export functionality is implemented in Notes though??
Thanks again for all your help.
it does get all the necessary text form the doc.
Do you know how the File->Export functionality is implemented in Notes though??
Thanks again for all your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot. As always your comments and suggestions are most valuable.
Rich Text is difficult to do correctly, straight text, no embedded pictures or attachments is not to hard.
It may be best to buy a third party add in that handles this if you plan to do it regularly.
I hope this helps !