Problem solve Get help with specific problems with your technologies, process and projects.

Scheduling agents in a view

I created a mail in a database that users will use to send scheduled e-mails. I created an action button, a scheduled send and a hidden field scheduled date. When a user clicks scheduled send, a prompt will appear where the user will fill in the date and time of delivery. This doc will be then saved as a draft. A view has been created that captures docs where the scheduled date is not blank. How do I create an agent that will open this view, go to the first document and see if the scheduled date is less then now, send, save and flag the message. How do I flag the message indicating it has been sent? Flagged messages will not show in the view.
I would create a flag field, SendFlag, and when a document is created that is to be sent at a scheduled time, set the field to "NeedToSend." Change your view selection criteria to only select documents where SendFlag = "NeedToSend." Sort the view by date and time so the earliest dates and times are first.

You could have an agent similar to the one below scheduled to run hourly.

Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim view As NotesView
  Dim doc As NotesDocument
  Dim docNext As NotesDocument
  Dim dtNow As New NotesDateTime( "" )
  Dim dtSend As New NotesDateTime( "" )
  Dim item As NotesItem
  Dim intProcess As Integer
  Set db = s.CurrentDatabase
  Set view = "scheduledmailview"
  Call dtNow.SetNow
  ' depending on how often your agent will run
  ' add minutes to the current time so it will
  ' include documents scheduled to be sent within
  ' that time period.
  Call dtNow.AdjustMinute( 35 )
  Set doc = view.GetFirstDocument
  intProcess = True
  While (intProcess)
    Set item = doc.GetFirstItem( "sendDateTime" )
    Set dtSend = item.DateTimeValue
    If (dtSend < dtNow) Then
      Set item = doc.ReplaceItemValue ( "SendFlag", "Sent" )
      Call doc.Send(False)
      Call doc.Save(True, False)
      intProcess = False
      Set doc = dc.GetNextDocument(doc)
End Sub

Dig Deeper on Lotus Notes Domino Agents

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...