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.

5 thoughts on “Notes Cannot Do This? Client Defined Delivery Schedule

  1. You can actually send a scheduled email with Lotus Notes out-of-the-box, as follows:

    Create a reminder in your calendar at the needed time and date. Give it the desired subject and body (including attachments, if necessary). Under the “Notify Me” options, select “Send mail notification”, and enter the neccessary recipients.

    It will prepend “Alarm:” to the subject and provide a link to the calendar entry, neither of which may be desirable in your setting; but it does do the job.

  2. Hello Ulrich,

    this “feature” has been implemented by a very big “German Bank” in their old R4 mail template in the late 90’s.

    But not so smart as you did… ๐Ÿ˜‰

    Yours, Renรฉ

  3. Hi,

    since i got a lot of time today at work (yes i work between the years) i tried this on our 7.0.3 servers.
    The first thing i ran to is that i need a dedicated agent for each mailX.box (we have 4 on each server). so this might be a small problem for admins. don’t forget to:

    – add an extra line in notes.ini at the end when adding it as a new parameter
    – disable agent trigger in the agent itself

    what i also found out is that the date-header in the outgoing smtp-mail is not altered, so in my tests the date and time of mail-creation (not mail delivery) is shown.

    and i need to add some code for:
    – delivery notice to sender, when message is delivered
    – delivery time hint in sent messages (like follow up)

    but if you can help me i would be very happy ๐Ÿ™‚

    Steffen

Comments are closed.