title: IBM Notes - Create an agent to send mail on user input date
body: <p>I created a form which consists of a button to send mail notification to the user. I need a scheduled agent to <strong>send mail on the user input date</strong>. Thank you.</p>
  
  <p>Here is the code for the button:</p>
  
  <pre><code>Sub Click(Source As Button)
      Dim incharge As String
      Dim Session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.CurrentDatabase
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim varValues As Variant
      Dim varCC As Variant
  
      Set uidoc = ws.currentDocument
      Set doc = uidoc.Document
      varCC = "(the CC address)"
      varValues = doc.GetItemValue( "incharge" )
      Dim email As NotesDocument
      Set email = db.CreateDocument
      email.Form="project"
      email.Principal="(the sender address)"
      email.Subject="(subject)"
      email.CopyTo=  varCC
      If Not Isnull( Arraygetindex( varValues, "Employee 1" ) ) Then
      email.Body = "Message"
      email.SendTo = "Employee 1 Address"
      Call email.Send(False)
      Else
      End If
      If Not Isnull( Arraygetindex( varValues, "Employee 2" ) ) Then
          email.Body = "Message"
          email.SendTo = "Employee 2 Address"
          Call email.Send(False)
      Else
      End If
      If Not Isnull( Arraygetindex( varValues, "Employee 3" ) ) Then
          email.Body = "Message"
          email.SendTo = "Employee 3 Address"
          Call email.Send(False)
      Else
      End If
      If Not Isnull( Arraygetindex( varValues, "Employee 4" ) ) Then
          email.Body = "Message"
          email.SendTo = "Employee 4 Address"
          Call email.Send(False)
      Else
      End If
      If Not Isnull( Arraygetindex( varValues, "Employee 5" ) ) Then
          email.Body = "Message"
          email.SendTo = "Employee 5 Address"
          Call email.Send(False)
      Else
      End If
      If Not Isnull( Arraygetindex( varValues, "Employee 6" ) ) Then
          email.Body = "Message"
          email.SendTo = "Employee 6 Address"
          Call email.Send(False)
      Else
      End If
  End Sub
  </code></pre>
  
  <p>This code sends the mail once the button is clicked. Thank you!</p>