My code below does not go to next document and adjust 5 business days of DateCreated and send message.Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim doc As NotesDocument
Dim mailDoc As NotesDocument, bodyDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim view As notesview
Dim theday As New NotesDateTime(Today)
Dim key As Variant
Set db = Session.CurrentDatabase
Set view = db.GetView("DirReminder")
Set doc = view.getfirstdocument
key = doc.DateCreated(0)
Ajust to 5 busienss days.
Dim recdbdate As New NotesDateTime(key)
Call recdbdate.AdjustDay(+5)
While Not (doc Is Nothing)
’ Compare adjusted date to today’s date
If (recdbdate.LSLocalTime = theday.LSLocalTime) Then
Set mailDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( mailDoc, "Body" )
mailDoc.Form = "Memo"
mailDoc.Subject = "test db: Reminder Notification"
Call rtitem.AddNewLine(1)
Call rtitem.appendtext ("This notification is being sent to you as a reminder to complete the form.")
Call rtitem.AddNewLine(2)
Call rtitem.AppendText("Thank you for your participation. >>" )
Call rtitem.AppendDocLink(doc, maildoc.Subject(0))
mailDoc.~_ViewIcon = 31
Call mailDoc.send( True, False )
End If
Set doc = view.getnextdocument(doc)
Wend
Ok That is resolved but it does not go to next doc and adjust datecreated to 5 days and send another mail. I also need to add 5 business weekday and eliminate weekends.
That’s because the date adjustment occurs outside the loop. It takes the creation date of the first document in the view and uses that throughout the loop. Move those lines down into your loop and it should work better.
Sub Initialize
Dim session As New NotesSession
…
Set db = Session.CurrentDatabase
Set view = db.GetView("DirReminder")
Set doc = view.getfirstdocument
While Not (doc Is Nothing)
key = doc.DateCreated(0)
' Adjust to 5 busienss days.
Dim recdbdate As New NotesDateTime(key)
Call recdbdate.AdjustDay(+5)
' Compare adjusted date to today's date
…
Set doc = view.getnextdocument(doc)
Wend
End Sub
I would also just use 7 days instead of trying to figure out whether the 5 days involved include holidays or weekends. Of course, you could write a module that would check on whether the intervening days are weekends or holidays, but check with your business people before spending a week coding that.