Late Notice E-mail Agent (Used in Domino.Doc 2.5a)

Mindwatering Incorporated

Author: Tripp W Black

Created: 05/10/2001 at 02:04 PM

 

Category:
Notes Developer Tips
Agents

This agent goes through the documents of a view and send each person a reminder if a document field value is more than x number of days older than today. An e-mail is sent to each user with a web link to that document. The web link has syntax on it that allows the link to bring up the proper frameset in a Domino.doc 2.5a window.

Option Public
Option Declare

Sub Initialize
Dim s As NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument
Dim maildoc As NotesDocument
Dim checkdate As NotesDateTime
Dim codate As NotesDateTime

' maildoc dims
Dim Body As NotesRichTextItem
Dim serverstring

' profile dims
Dim pview As NotesView
Dim pdoc As NotesDocument
Dim pbody As NotesRichTextItem

Set s = New NotesSession
Set db = s.CurrentDatabase
Set v = db.GetView("CODocs")
Set checkdate = New NotesDateTime("Today")
Call checkdate.AdjustDay( -6 )

' Get the system profile doc for mail reminders
Set pview = db.GetView("SysAdmin")
Set pdoc = pview.GetDocumentByKey ("COReminderProfile", True)

Set doc = v.GetFirstDocument
While Not doc Is Nothing
' Compare dates to see if notice needs to be sent to user
Set codate = New NotesDateTime(doc.CheckOutDateTime(0))
If checkdate.TimeDifference( codate ) > 0 Then
Set maildoc = New NotesDocument( db )
maildoc.Form = "Memo"
maildoc.Subject = "Reminder: Checked Out Document - " & doc.Title(0)

If pdoc Is Nothing Then
Set Body = New NotesRichTextItem ( maildoc, "Body" )
Call Body.AppendText _
( "The following document has been checked out for longer than 7 days. ")
Call Body.AddNewLine( 1 )
Call Body.AppendText _
( "Please follow the link to the document below, review the document, and check it into the system. ")
Call Body.AddNewLine( 1 )
maildoc.From = "Jane Doe/ACME/Mindwatering"
maildoc.Principal = "Jane Doe/ACME/Mindwatering"
Else
Set pbody = pdoc.GetFirstItem( "Body" )
Call pbody.CopyItemToDocument( maildoc, "Body" )
Set Body = maildoc.GetFirstItem( "Body" )
maildoc.From = pdoc.MailName(0)
maildoc.Principal = pdoc.MailName(0)
End If
serverstring = Strleftback(db.server, "/O=", 5)
serverstring = Strright(serverstring, "CN=", 5)
Call Body.AddNewLine( 1 )
Call Body.AppendText _
("http://" & serverstring & "/" & doc.FileCabinetReplicaID(0) & "/WebAllBindersFrameset?OpenFrameSet&Frame=Right&Src=All+Documents/" & doc.DocUNID(0) )

Call Body.AddNewLine( 2 )
Call Body.AppendText ("Thank you." )
Call Body.AddNewLine( 1 )
If pdoc Is Nothing Then
Call Body.AppendText ("Sondra." )
Else
Call Body.AppendText (pdoc.Name(0))
End If
Call maildoc.Send( False, doc.CheckOutUser(0) )
End If
Set doc = v.GetNextDocument(doc)
Wend
End Sub

previous page