Debug message - object variable not set

Hi All,This agent can send a reminder to the current author every 2 day.

I had debug the script & got an error message as “Object Variable Not Set” on the Function fncNotify as show as attachment below:-

Sub Initialize

On Error Goto ErrorHandler

Dim docP As NotesDocument

Set db = session.CurrentDatabase

Set view = db.GetView( "Reminder" )  //the view that contain pending request



Set doc = view.GetFirstDocument







While Not doc Is Nothing

	' Initial

	

	statusNo= doc.GetItemValue( "RequestNo" )(0)	

	requester = doc.GetItemValue( "tRequester" )

	reqManager= doc.GetItemValue( "TransfererHOD")

	TransfereeHOD = doc.GetItemValue("TransfereeHOD")

	

	

	continue$ = "No"

	

	

	If doc.GetItemValue( "Status" )(0) = "Submitted"  Then

		msgCode$ = 	"CT001"    // CT001 get retrive from the Message Code   profile .This Message Code profile contain the day of the first & subsequent notification                                                   

		continue$ = "Yes"				

		sendPerson = reqManager

		

		daysdiffer% = Cint( Datevalue( Today ) - Datevalue( doc.GetItemValue( "SubmittedDate" )(0) ) )

		

	Elseif doc.GetItemValue( "Status" )(0) = "Transferor HOD Approved" Then

		msgCode$ = 	"CT002"   // CT002 get retrive from the Message Code   profile .This Message Code profile contain the day of the first & subsequent notification                                                   

		continue$ = "Yes"				

		sendPerson = TransfereeHOD

		

		daysdiffer% = Cint( Datevalue( Today ) - Datevalue( doc.GetItemValue( "TransfererAprDate" )(0) ) )

		

		

	End If

	

	

	If continue$ = "Yes" Then

		' Get message frequency

		Call fncGetMessageFrequency( msgCode$, firstRemind%, subRemind% )

		

		'Notification process

		If daysdiffer% > 0 Then

			If daysdiffer% < firstRemind% Then

				'Do nothing

			Elseif daysdiffer% = firstRemind% Then

				Call fncNotify( msgCode$,"", doc )

			Elseif subRemind% > 0 Then		 'Implied daysdiffer% > firstRemind% 

				If (daysdiffer% - firstRemind%) Mod subRemind% = 0  Then

					Call fncNotify( msgCode$, "" , doc )

				End If

			End If

		End If

	End If

ResumeNext:

	Set doc = view.GetNextDocument( doc )

Wend

Exit Sub

ErrorHandler :

Msgbox "Auto Send Reminder Agent error: " & Error(Err) &  Cstr(Erl) 

Goto ResumeNext

End Sub

fncGetMessageFrequency

= = = = = = = = = = = = =

Function fncGetMessageFrequency( msgCode As String, firstRemind As Integer, subRemind As Integer )

On Error Goto ErrorHandler

Dim view_message As NotesView

Dim doc_message As NotesDocument

Dim db_message As NotesDatabase

Dim ss As New NotesSession



Set  db_message = ss.CurrentDatabase

Set view_message = db_message.GetView( "vwMessageCode" )



Set doc_message = view_message.GetDocumentByKey(msgCode)

Set doc_message = view_message.GetFirstDocument



If  Not doc_message Is Nothing Then

	

	If Not Isnumeric( doc_message.GetItemValue( "MsgFirstReminder" )(0) ) Then

		firstRemind = 0

	Else

		firstRemind = doc_message.GetItemValue( "MsgFirstReminder" )(0)

	End If

	If Not Isnumeric( doc_message.GetItemValue( "MsgSubReminder" )(0) ) Then

		subRemind = 0

	Else

		subRemind = doc_message.GetItemValue( "MsgSubReminder" )(0)	

	End If

End If



Exit Function

ErrorHandler :

Msgbox "Function GetMessage Agent error: " & Error(Err) &  Cstr(Erl) 

End Function

fncNotify

= = = = = =

Function fncNotify( messagecode As String, sendPerson As Variant,_

doc As NotesDocument )

On Error Goto ErrorHandler



'## Notify Process

Dim MEMO As New Email

 MEMO.MessageCode= messagecode //the debug script stop in here, & get the error msg as “Obeject Variable Not Set”

MEMO.SendTo = sendPerson





MEMO.Subject = "Computer Transfer #" & doc.GetItemValue( "RequestNo" )(0) & ": " & MEMO.Subject



Call MEMO.Body.AppendText( link$ )



Call MEMO.Send( Nothing )

Set MEMO =Nothing





Exit Function

ErrorHandler :

Msgbox "Notify function error: " & Error(Err) &  Cstr(Erl) 

End Function

Subject: debug message - object variable not set

The MEMO object is not set

Not sure whereabouts in the code the EMail class is set

You will need to trap the line causing the problem by putting an “If Not(MEMO is Nothing)” statement around it and trapping it properly

Mike

Subject: RE: debug message - object variable not set

Hi Mike,My Email library only 've " Option Public" . Isn’t anything that i need to add in the library? Thanks.