Object Variable Not Set

I found the following code in the SandBox (search for SMTP Header). It was written for R5 which displays the message headers for an email with the ability to send to someone or print it. When I try to send it, I get “Object Variable Not Set”, but I don’t know why it’s not working - any help is appreciated - thanks!

Sub Initialize

Dim doc As notesdocument

Dim uidb As notesuidatabase

Dim db As notesdatabase

Dim collection As notesdocumentcollection

Dim nSuccess As Integer

Dim uiws As New notesuiworkspace	

Set uidb = uiws.currentdatabase

Set db = uidb.database

Set collection = db.UnprocessedDocuments

If collection.count > 0 Then

	Set doc = collection.GetNthDocument(1)

	nSuccess = uiws.dialogbox("(DDI)",True,True,True,False,False,False,"Detailed Delivery Information",doc,True,True)

End If

End Sub

Subject: Please start by reading this technote

What does the error “Object variable not set” mean?For your future reference. In this case, I don’t see why you’re going to all the trouble to find out what is the current document and pass it to dialogbox. If you just invoke dialogbox without supplying a document, it’ll display the current document by default. You can even use macro language.