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
mailed.
The components of the subform are:
The Dummy Field;
Translation Formula: @DeleteField
Validation Formula:
@If(!@IsDocBeingMailed;@Return(@Success);"");
ENVIRONMENT EnvBeingMailed:="1";
ENVIRONMENT EnvDelay:="1";
@SetEnvironment("JonDelay";"");
@SetEnvironment("JonDelay";"1");
@SetEnvironment("JonDelay";"");
@SetEnvironment("JonDelay";"1");
@SetEnvironment("JonDelay";"");
.
-
This is called around 90 times

@Success

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")
FooterTimer.interval=1
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

BeingMailed=Session.GetEnvironmentString("EnvBeingMailed")
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
WasError:
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
Line=Chr$(10)+Space$(10)+String$(30,"_")
Footer="This is the footer"
Set rtStyle=Session.CreateRichTextStyle
rtStyle.Bold=True
rtStyle.Effects=EFFECTS_NONE
rtStyle.FontSize=18
rtStyle.Italic=False
rtStyle.NotesColor=COLOR_BLACK
rtStyle.NotesFont=FONT_HELV
rtStyle.Strikethrough=False
rtStyle.Underline=False
Call rtItem.AppendStyle(rtStyle) 'Defines the style in bold
Call rtitem.AppendText(Line) 'Appends a line
rtStyle.Bold=False
rtStyle.FontSize=8
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
WasError:
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
QuerySend.
This was last published in November 2000

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • 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 ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close