You must specify a parent database

I have an agent (code below) in which I want to fax the selected documents to a field FAXnr which is in each document.However, with this piece of code I get the message “You must specify a parent database”. What am I doing wrong?

Sub Initialize

Dim wk As New NotesUIWorkspace

Dim ss As New NotesSession

Dim db As NotesDatabase

Dim uidoc As NotesUidocument

Dim doc As NotesDocument

Dim EsCC() As String

Dim dateTime As NotesDateTime

Dim item As NotesItem	

Dim maildoc As NotesDocument

Dim rtitem As NotesRichTextItem

Set maildoc=New NotesDocument(db)

maildoc.SendTo=doc.FAXnr(0)

maildoc.Subject = "blablabla - " + doc.QCIR_Nr(0)

Set rtitem = New NotesRichTextItem( mailDoc, "Body" )

Call rtitem.AppendText("Dear, " )

Call rtitem.AddNewLine(2)	

Call rtitem.AppendText( "blablabla."  )

Call rtitem.AddNewLine(2)	

Call rtitem.AppendText( "Best regards."  )

Call rtitem.AddNewLine(2)			

Call rtitem.AppendText(" ")

maildoc.Send(0)

Call doc.save(True,True)

Call uidoc.Close 

End Sub

Subject: You must specify a parent database

Well, the first things that I see are that you Dim db and doc, but you don’t set them to anything. And your uidoc.Close won’t work cause you haven’t set uidoc to anything.

Subject: You must specify a parent database

You need Set db = ss.CurrentDatabase line before setting maildoc.

Konrad

Subject: You must specify a parent database

Ok, I have done so, and now I get “object variable not set” onSet doc=uidoc.document.

I repeat the code :

Sub Initialize

Dim wk As New NotesUIWorkspace

Dim ss As New NotesSession

Dim db As NotesDatabase

Dim uidoc As NotesUidocument

Dim doc As NotesDocument

Dim maildoc As NotesDocument

Dim rtitem As NotesRichTextItem

Set db = ss.CurrentDatabase

Set uidoc=wk.currentdocument

Set doc=uidoc.document	

Set maildoc=New NotesDocument(db)

maildoc.SendTo=doc.FAXnr(0)

maildoc.Subject = "bla bla bla - " + doc.QCIR_Nr(0)

Set rtitem = New NotesRichTextItem( mailDoc, "Body" )

Call rtitem.AppendText("Dear, " )

Call rtitem.AddNewLine(2)	

Call rtitem.AppendText( "bla bla bla."  )

Call rtitem.AddNewLine(2)	

Call rtitem.AppendText( "Best regards."  )

Call rtitem.AddNewLine(2)			

Call rtitem.AppendText(" ")

maildoc.Send(0)

Call doc.save(True,True)

'Call doc.Close 

End Sub

can you help me further? As you can see I have very little notice of Lotus Script.

Subject: RE: You must specify a parent database

Where do you have this code? Is a document open on the workspace when it is executed?