NO form associated with document

I’m working on agent that simply sends out a email based on a search formula and I’m getting the error “No Form Associated with Document”. Can anyone see my error?

Thanks in advance.

Declarations

Dim s As NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim emaildoc As NotesDocument

Dim collection As NotesDocumentCollection

Sub Initialize

Set s = New NotesSession

Set db = s.CurrentDatabase





searchFormula$= "Form = ""Employee""" 

Set collection = db.Search(searchFormula$,Nothing,0)



' For each document send a reminder to the appropriate person



Dim person  As String 



For i = 1 To collection.Count

	

	

	Set doc = collection.GetNthDocument(i)

	Set emaildoc = db.createdocument

	

	rawperson= doc.getitemvalue("Employee")

	person =Cstr(rawperson(0))

	

	'Msgbox(person)

	

	person2 = "Charles McCutchen"

	

	emaildoc.Form = "Reminder"	

	emaildoc.Subject="Reminder to fill out weekly timesheet"

	Set emaildoc = db.createdocument		

	emaildoc.Send True, person2	

	

Next	

End Sub

Subject: NO form associated with document

Hi Charles,

You create emaildoc twice, and the 2nd time there is no form associated. (it’s a new object)

So remove the set-line above the send line and it’ll work

emaildoc.Subject=“Reminder to fill out weekly timesheet”

Set emaildoc = db.createdocument <— remove this line

emaildoc.Send True, person2

Regards,

René

Subject: RE: NO form associated with document

That was just a test Renee. :slight_smile: You passed.

Thanks!

Subject: RE: NO form associated with document

emaildoc.Form = “Reminder” …

emaildoc.Send True, person2

Why are you attaching a form? (hint: don’t).