Notes Cannot Do This? Client Defined Delivery Schedule
I found this idea on IdeaJam today. There have been several questions regarding scheduled mails in almost all Lotus Notes related forums in the past years and as far as I recall, Breaking Par has had a solution for this.
Although I do not see any business case for this feature, I like the idea. And yes, Notes cannot do this out of the box. But let’s see, if we can find a solution. As I commented, you can use Trigger Happy to achieve the goal. The solution only needs minor changes on the mail template.
I use Notes and Domino 8.0.1 but the agent code and the modification might work on every other Notes version. I assume that you already have Trigger Happy installed on your server.
Create two new fields in the DelOptions subform. DeliveryDate and DeliveryTime.
and save the subform.
Create an new agent in the triggerhappy.nsf and copy the following code into the agent:
'Agent ScheduledMails
'++Options
Option Public
Option Explicit
'++ Declarations
Const SCHEDULED_MAILS = {@IsAvailable("DeliveryDate") & RoutingState="HOLD"}
Sub Initialize
On Error Goto processError
Dim session As New NotesSession
Dim doc As NotesDocument
Dim item As NotesItem
Dim Scheduled As String
Dim dtNow As New NotesDateTime(Now)
Dim mailbox As New NotesDatabase ( "Serv01/singultus","mail.box" )
Dim col As NotesDocumentCollection
Dim i As Integer
'** make sure we don't mess up the rich text fields stored as MIME
session.ConvertMime = False
Set doc = session.DocumentContext
'** check new mails
If doc.HasItem("DeliveryDate") And (Not doc.HasItem("RoutingState" )) Then
If Trim(doc.DeliveryDate(0)) <> "" Then
Scheduled = _
"Message delivery scheduled: " _
& Cstr(doc.DeliveryDate(0)) & " " & Cstr(doc.DeliveryTime(0))
Print scheduled
doc.RoutingState = "HOLD"
doc.FailureReason = Scheduled
Call doc.save(False,False)
End If
End If
'** scheduled mails to deliver ?
If mailbox.IsOpen() Then
Set col = mailbox.Search(SCHEDULED_MAILS,Nothing,0)
Set doc = col.GetFirstDocument
While ( Not doc Is Nothing )
Dim dtSched As New NotesDateTime _
( Cstr(doc.DeliveryDate(0)) & " " & Cstr(doc.DeliveryTime(0)) )
If dtSched.localtime <= dtNow.LocalTime Then
Call doc.RemoveItem ("RoutingState")
Call doc.RemoveItem ("FailureReason")
Call doc.Save(False,False)
End If
Set doc = col.GetNextDocument(doc)
Wend
End If
session.ConvertMime = True
Exit Sub
processError:
'** use your favorite error logging routine here
Exit Sub
End Sub
Create a trigger in the configuration database.
and save it. Every time, a new mail arrives in the mail.box, the agent is invoked. It checks the new mail, if it has a DeliveryDate item and if the item contains a value.
If so, the RoutingState is set to HOLD. The router will stop to deliver the mail. The second step is to check if the the delivery date and time is reached. If so, the agent removes the RoutingState field from the document and the router will process the document and deliver it.
The FailureReason column contains a hint that the mail is scheduled.