Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import RTF docs from SQL to Notes via VB

Status
Not open for further replies.

StephHansen

Programmer
Dec 26, 2001
87
IN
Does anyone know how to take documents that are stored in SQL as rtf and put them in Lotus Notes? I either need to have them in a Rich Text field as an attachment or have the entire output go in that field. Either way, I don't care. I am using Notrix but they do not have a way to tunnel that data. Any ideas?
Thanks so much! Stephanie Nicholas
Software Engineer
i-Net Strategy
 
Hello

The following code allows you to connect to a Notes database and create a document with some text and an attachment.

Code:
Dim NotesSesion As Object, DB as variant, NewDoc As Variant, BodyText As Variant, AttachMent As Variant

Set NotesSesion = CreateObject("Notes.Notessession")
Set DB = NotesSesion.GetDatabase("Server Name", "Database name")

Set NewDoc = DB.CreateDocument
NewDoc.Form = "FormName"
NewDoc.replaceitemvalue "FieldName", FieldValue  'not for rich text items
Set BodyText = NewDoc.createrichtextitem("Attachment Area")
Call BodyText.appendtext("Some text" + vbCrLf)

Set AttachMent = BodyText.embedobject(1454, "", "C:\My Attachment")
Set AttachMent = Nothing

Call NewDoc.Save(True, False)

Set Recipian = Nothing
Set BodyText = Nothing
Set NotesSesion = Nothing

You can make it easier on yourself by referencing the Domino object model. Essentially once you create a session and database object you can do the same as in any Notes script.

Hope this helps
 
That's Lotus Script? How would that grab docs out of a SQL table? the docs are stored as "Text" in the SQL table and not in a folder.

Thank you so much for your help, I do appreciate it!
Stephanie Nicholas
Software Engineer
i-Net Strategy
 
Hello

Yes, once you reference the Domino objects in VB you have the same functionality as Lotus Script.

When you say the docs are stored as text do you mean;
a) The document is stored as a streaming blob object
b) As the Rtfs contents in a large char field

If a then you will need to extract the file from SQL and store it in a temp location on the hard drive then attach it to Notes.
If b then you can pump the field directly into Notes as text or extract it to the harddrive and attach it as a file.

Essentially, the VB application will run against the database where you can decide whether to store the field as a file or to use it as text and then apply the code I indicated before.

PS The code I've shown is based on Visual Basic code. There are ways of referencing the ADODB object class in Lotus script but it is much easier in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top