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) Else intProcess = False EndIF Set doc = dc.GetNextDocument(doc) Wend End Sub
Dig Deeper on Lotus Notes Domino Agents
Related Q&A from Brian Mahoney
Find out what types of calculations can be computed for a column in a Lotus Notes view and the best way to go about it with this expert response. Continue Reading
Find out why you can't use Formula language to include a doclink to a specific Lotus Notes view or database and need to use LotusScript instead. Continue Reading
Discover the reasons behind a Notes/Domino admistrator having trouble with disabled options in the "customize this view" section of his Lotus Notes ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.