porkchop1214
MIS
Finally, I could do the job, here is the sample code to export the fields and attachments for a notes database....., I have hardcode the "export path"
I could use this code to export the PDF, word and excel rather than rtf...
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
REM Opened Database
Set db = session.GetDatabase("swan", "test\memo",False)
If Not db.IsOpen Then
Messagebox "database cannot be opened",,"cannot opened"
Else
Messagebox db.Title,, "opened"
End If
REM ____________________________________________________________
REM Create note collection
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
Call nc.SelectAllNotes(True)
Call nc.BuildCollection
REM get doc
Dim doc As NotesDocument
Dim view As NotesView
Dim x As Integer
Set view = db.GetView( "ByIssuedDate" )
Set doc = view.GetFirstDocument
x = 0
Dim fileNum1 As Integer
Dim fileName1 As String
Dim object As NotesEmbeddedObject
Dim str1 As String
Dim att As NotesEmbeddedObject
fileNum1% = Freefile()
fileName1$ = "c:\export\memo\file.txt"
Open fileName1$ For Output As fileNum1%
While Not (doc Is Nothing)
x = x + 1
Forall i In doc.Items
Write #fileNum1%, x, " ", i.name, " ", doc.GetItemValue (i.name)(0)
If i.name = "$FILE" Then
str1= doc.GetItemValue(i.name)(0)
End If
End Forall
Set object = doc.GetAttachment(str1)
If Not (object Is Nothing) Then
Call object.ExtractFile("c:\export\memo\" & str1)
End If
Set doc = view.GetNextDocument(doc)
Wend
Write #fileNum1%, "Total Record = ", x
Close fileNum1%
End Sub
Kill Ghost Prince
I could use this code to export the PDF, word and excel rather than rtf...
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
REM Opened Database
Set db = session.GetDatabase("swan", "test\memo",False)
If Not db.IsOpen Then
Messagebox "database cannot be opened",,"cannot opened"
Else
Messagebox db.Title,, "opened"
End If
REM ____________________________________________________________
REM Create note collection
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
Call nc.SelectAllNotes(True)
Call nc.BuildCollection
REM get doc
Dim doc As NotesDocument
Dim view As NotesView
Dim x As Integer
Set view = db.GetView( "ByIssuedDate" )
Set doc = view.GetFirstDocument
x = 0
Dim fileNum1 As Integer
Dim fileName1 As String
Dim object As NotesEmbeddedObject
Dim str1 As String
Dim att As NotesEmbeddedObject
fileNum1% = Freefile()
fileName1$ = "c:\export\memo\file.txt"
Open fileName1$ For Output As fileNum1%
While Not (doc Is Nothing)
x = x + 1
Forall i In doc.Items
Write #fileNum1%, x, " ", i.name, " ", doc.GetItemValue (i.name)(0)
If i.name = "$FILE" Then
str1= doc.GetItemValue(i.name)(0)
End If
End Forall
Set object = doc.GetAttachment(str1)
If Not (object Is Nothing) Then
Call object.ExtractFile("c:\export\memo\" & str1)
End If
Set doc = view.GetNextDocument(doc)
Wend
Write #fileNum1%, "Total Record = ", x
Close fileNum1%
End Sub
Kill Ghost Prince