Domino Code Fragment

Code Name*
Daily Dilbert Agent
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.191.195.110
Description*
This agent is hardcoded to the specific URL to retrieve the daily dilbert page that is available and send it to a user. It should be run in the background on the server.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Dim LastYear As String
Dim LastMonth As String
Dim LastDay As String
Dim LSLastWeek As Variant


Dim db As Notesdatabase
Dim Doc As Notesdocument
Dim URLBase As String

Dim URL_field As String
Dim urls As Variant
Dim newdoc As notesdocument
Dim memo As notesdocument

Sub Initialize
Dim LastWeek As New Notesdatetime("Today")
Dim s As New Notessession

REM Find the date for 8 days ago since that is the delay on the Web

Call LastWeek.AdjustDay (-8)
LSLastWeek = LastWeek.LSLocalTime
LastYear = Mid$(Cstr (Year (LSLastWeek)), 3, 2)
LastMonth = Cstr (Month (LSLastWeek))
If (Len(LastMonth) = 1) Then
LastMonth = "0" + LastMonth
End If
LastDay = Day (LSLastWeek)
If (Len(LastDay) = 1) Then
LastDay = "0" + LastDay
End If

URLBase = "http://www.unitedmedia.com/comics/dilbert/archive/dilbert" + LastYear + LastMonth + LastDay

REM Reload the Dilbert Archive page so we can scan it and be sure to save the URL List on it

Set db = s.CurrentDatabase
Set Doc = db.GetDocumentbyurl("http://www.unitedmedia.com/comics/dilbert/archive/", 1, 1)

REM Get the URL list off the archive page and scan for a match of the first part

URL_field = "$URL1"
URLs = Doc.GetItemValue(URL_field)

Forall u In URLs
If Instr(1, u, URLBase) = 1 Then
Set newdoc = db.GetDocumentByURL(u, 1, 1)
Set memo = New NotesDocument( db )
Set Body = New NotesRichTextItem(memo, "Body")
Body.AppendText("This is the URL for today's Dilbert page: "+u)
Body.AddNewLine(2)
Call memo.ReplaceItemValue( "Subject", "The Daily Dilbert page" )
Call memo.ReplaceItemValue( "Form", "Memo" )
Call memo.Send( False, "MyName@MyDomain" )
End If

End Forall
End Sub