It's send mail regardless Status?

It’s a schedule agent.Document Selection is used.

Have a Statusfield and if Status=“1” the agent should run and only then. Problem is that the agent run regardless status.

Could anyone see what i did wrong!

Sub Initialize

On Error Goto errProc



Dim session As New NotesSession

Dim SourceDoc As NotesDocument

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim Item As NotesItem

Dim vValues As Variant

Dim aValues As Variant

Dim maildoc As NotesDocument

Dim upperBound As Integer

Dim MailNames(10) As String

Dim buildsubject As String

Dim dbWebPath As String

Dim temp As Variant

'Set email distribution list

Set db = session.CurrentDatabase

Set doc = session.DocumentContext

Set maildoc = New NotesDocument( db )

Set profileDoc = db.GetProfileDocument("KeyWords")



If(doc.Status(0)="1")	 Then

'Convert this to a NotesName

	temp = Evaluate({@Do(server := ""; database := ""; view := "(CheckActiveUser)"; key := "Active"; columnNumber := 2;Choise := @DbLookup( "Notes" : "NoCache" ; server : database ; view ; key ; columnNumber); @If(@IsError(Choise);"";@Trim(@Unique(Choise))))})

	MailNames(0)=temp

			

	'Set the To, Subject and Body fields

	maildoc.Form="Memo" 

	maildoc.SendTo=MailNames

	sender=profileDoc.ServerMail(0)

	maildoc.from=sender

	maildoc.SMTPOriginator=sender

	maildoc.Principal=sender

'Format the document

	buildsubject = profileDoc.NotifySubject(0)

	maildoc.Subject = buildsubject

	maildoc.Body = profileDoc.NotifyMessage(0) 

	Call maildoc.Send(False)

	

End If

errProc:

Resume Next 

End Sub

Kind regards

Fredrik