Manage Learn to apply best practices and optimize your operations.

Add A Forced Footer To A Message

The first temptation was to use the QuerySave event, to add the footer to the
body of the message, but this event is only called when the message is saved.
By adding a dummy hidden editable field at the end of the form, it is possible
to validate the message, before sending it, but there is no way via formulas to
modify the body field that is a rich text.
The solution was to include a subform, the dummy field is included in that
subform. In the postopen event of the same subform: an evironment variable is
initialized, and a NotesTimer object is defined with an interval of one second.
The subroutine called by the timer checks the flag variable in the environment,
to know if the document is being mailed. In case the document is being mailed,
the footer is added to the end of the body field.
The ugly part of the solution is how to make sure that the timer is called
before the document is sent. The solution I found was to define the flag for
marking the document as being sent, at the beginning of the validation formula,
after that I write and rewrite around 90 times an evironment variable, this was
the slowest formula function I could think of, that did'nt create traffic in
the network. This was calibrated with the fastest machine. It could be improved
by verifying the time spent and execute only the needed delay.

This way the validation formula sets the trigger and the writing and rewriting
of environment variables makes sure the timer is called before the document is
being sent. This works when the document is saved and when the document is just
The components of the subform are:
The Dummy Field;
Translation Formula: @DeleteField
Validation Formula:
ENVIRONMENT EnvBeingMailed:="1";
ENVIRONMENT EnvDelay:="1";
This is called around 90 times


On the Globals Declarations of the subform
Dim FooterTimer As NotesTimer

The PostOpen event of the subform
Sub Postopen(Source As Notesuidocument)
Dim Session As New NotesSession
Call Session.SetEnvironmentVar("EnvBeingMailed","")
Set FooterTimer=New NotesTimer(1,"Timer for the Footer")
On Event alarm From FooterTimer Call Footer
End Sub

A subroutine Footer is defined in the Globals Part of the SubForm
Sub Footer(NTimer As NotesTimer)
On Error Goto WasError

Dim Session As New NotesSession
Dim Ws As New NotesUIWorkspace
Dim Uidoc As NotesUIDocument
Dim Doc As NotesDocument
Dim BeingMailed As String

If (BeingMailed="1") Then
Set Uidoc=Ws.Currentdocument
Set Doc=UiDoc.Document
Call SetFooter(Doc)
Call Session.SetEnvironmentVar("EnvBeingMailed","")
End If '(BeingMailed="1")
Exit Sub
Print "There was an error on the Footer:"+Error$
Exit Sub
End Sub

On the Options part of the Globals, a script library footer is called
Use "Footer"

This is defined in a script library, because the implementation for the web is
more straightforward, by means of the WebQuerySave Agent, so it is easier to
call the same subroutine in the WMemo agent.

The subroutine in the script library is:
Sub SetFooter(Doc As NotesDocument)
On Error Goto WasError
Dim Session As New NotesSession
Dim Footer As String
Dim Line as String
Dim rtitem As Variant
Dim rtStyle As NotesRichTextStyle

Set rtitem = Doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
Footer="This is the footer"
Set rtStyle=Session.CreateRichTextStyle
Call rtItem.AppendStyle(rtStyle) 'Defines the style in bold
Call rtitem.AppendText(Line) 'Appends a line
Call rtItem.AppendStyle(rtStyle) 'Switches to Plain
Call rtitem.AddNewLine(1) 'Appends a line
Call rtitem.AppendText(lFooter) 'Appends the footer
End If '( rtitem.Type = RICHTEXT )
Exit Sub
Print "Error in SetFooter:"+Error$
Exit Sub
End Sub

With this all that is needed is to insert the subform at the end of the Memo
form, and of every form where the footer should be enforced, like Reply, Reply
with History, etc.

In short the solution was to force an event that was not defined by Notes, like

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials'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 ...