CAVEAT: If the person's NAB document has the Mics. setting "Encrypt incoming mail" to "Yes", this agent can not read the rich text field. (This is working as designed, according to Lotus.)
'Send Pager Alert Agent (LS):
Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim dbCurrent As NotesDatabase
Dim collUnprocessed As NotesDocumentCollection
Dim docCurrent As NotesDocument
Dim itemBody As NotesItem
Dim strPriority As String, strImportance As String
Dim varBody As Variant
Dim strSendTo(1) As String
strSendTo(0) = "6109999999.0505245@PAGENET.NET" 'Pager Internet Address
strSendTo(1) = "2155551212@msg.celluar.com" 'Celluar pager address
Set dbCurrent = session.CurrentDatabase
If (dbCurrent Is Nothing) Then
Print "dbCurrent not set"
Else
Set collUnprocessed = dbCurrent.UnprocessedDocuments
If collUnprocessed.Count < 1 Then
Print "Nothing to process"
Else
Set docCurrent = collUnprocessed.GetFirstDocument
If (docCurrent Is Nothing) Then
Print "Could not get handle of current document"
Else
Do
strPriority = docCurrent.DeliveryPriority(0)
strImportance = docCurrent.Importance(0)
If ((docCurrent.Form(0) = "Memo") And (strPriority = "H" Or strImportance = "1")) Then
'Need to create new memo & send to pager.
Dim docPagerMemo As New NotesDocument(dbCurrent)
Dim varFrom As Variant, strSubject As String, strBodyText As String
Stop 'use for debugging
docPagerMemo.SendTo = strSendTo
varFrom = Evaluate({@Name([CN]; From)}, docCurrent)
strSubject = docCurrent.Subject(0)
Set itemBody = docCurrent.GetFirstItem("Body")
If (itemBody Is Nothing) Then
'Body can not be read
Print "itemBody not set"
docPagerMemo.Body = "Text can not be read. Check your email. | From: " & varFrom
Else
'If Body can be read, return only 200 characters
'break down variables for debugging
strBodyText = "From: " & varFrom(0) & " : " & strSubject & " - " & Left(itemBody.Text, 200)
docPagerMemo.Body = strBodyText
End If
Call docPagerMemo.Send(False)
Print "Page sent"
Call session.UpdateProcessedDoc(docCurrent)
End If
Set docCurrent = collUnprocessed.GetNextDocument(docCurrent)
Loop Until (docCurrent Is Nothing)
End If
End If
End If
End Sub
This was first published in February 2001