My problem is that it says that the Call Newsletterwithlist for the agent to the newsletter it says variable is not set and I can't seem to fix it. I have tried debugging it and can't not understand what it is missing when trying to link the two together. It doesn't give me the error inless I put in some error processing which then shows me it is on line 77 which I have Rem out up top so you can see. Can anyone please help me fix this?
Here is my Agent
Dim okayemail As Boolean
Dim debugsearch As Boolean
Dim logpath As String
Dim errorlist List As String
Dim AlertNotificationdoc As NotesDocument
Dim x As Integer
Dim AlertNotificationdc As NotesDocumentCollection
Dim AlertNotificationdb As NotesDatabase
Dim worksel As String
Dim selection As String
Dim LogDBV As Variant
Dim LogEntry As String
Dim workcount As Integer
Dim strfield As String
Dim timestamp As NotesDateTime
Dim LOGNAME As String
Const LOGagent = "SendAlert"
Dim user As NotesName
Dim samplist List As String
Dim servname As NotesName
Sub Initialize
On Error Goto ProcessError
Set s = New NotesSession
Set db = s.CurrentDatabase
server = db.server
Set timestamp = New NotesDateTime(Today)
REM Loading the database into the agent
LogDBV = GetKWV("LogDatabases")
Call AgentLogAction(LOGNAME, "<------Start------>")
Set servname = New NotesName(db.server)
LOGNAME = servname.Common & "-" & LOGagent
REM For debugging
If GetKW("Debug") = "1" Then
Debugsearch = True
Else
Debugsearch = False
End If
Forall LD In Logdbv
Logpath = LD
Set AlertNotificationdb = s.getdatabase(db.server,LD)
worksel = |(@created = @date(| & Year(timestamp.LSLocalTime) & |;| & Month(timestamp.LSLocalTime) & |;| & Day(timestamp.LSLocalTime) & |))|
selection = worksel
If debugsearch Then
Call AgentLogAction(LOGNAME, "selection= " & selection)
End If
Set AlertNotificationdc = AlertNotificationdb.Search( selection , Nothing , 0)
If Not AlertNotificationdc Is Nothing Then
Set AlertNotificationdoc = AlertNotificationdc.GetFirstDocument
While (Not AlertNotificationdoc Is Nothing)
strfield = AlertNotificationdoc.GetItemValue("A$LogType")(0)
If strfield = "Error" Then
REM when using fields with dollar signs you must use doc.getitemvalue("A$Logtime") (0)
errorlist(AlertNotificationdoc.UniversalID) =AlertNotificationdoc.GetItemValue("A$LogType")(0) & "~" & Alertnotificationdoc.GetItemValue("A$Logtime")(0) & "~" & AlertNotificationdoc.GetItemValue("A$Progname")(0)& "~" & Alertnotificationdoc.GetItemValue("A$User")(0) & "~" & Alertnotificationdoc.GetItemValue("A$Action")(0)& "~" & Alertnotificationdoc.GetItemValue("A$ERRMSG")(0)
okayemail=True
End If
Set AlertNotificationdoc =
AlertNotificationdc.GetNextDocument(AlertNotificationdoc)
REM sending it to a new database and checking for errors
Wend
End If
End Forall
REM Calling the e-mail letter
If okayemail Then
REM Line 77 below the whole call statement
Call NewWeeklyNewsletterwithlist(AlertNotificationdoc,GetKWNames("AlertNotification") ,"ErrorAlert")
End If
Exit Sub
Call AgentLogAction(LOGNAME, Cstr(workcount) & " Error emails sent") Call AgentLogAction(LOGNAME, "<------End ------>")
ProcessError:
Call AgentLogError(LOGNAME,0, "Line: " & Erl() & " Error:" & Err() & "=" & Error() )
Call AgentLogError(LOGNAME,0, " Error in " & (AlertNotificationdoc.Logpath(0)))
Resume Next
End Sub
Here is my Newsletter
Sub NewWeeklyNewsletterwithlist(AlertNotificationdoc As NotesDocument, Attention As Variant, Action As String)
On Error Goto ProcessError
Dim s As New NotesSession
Dim rtiText1 As NotesRichTextItem
Dim rtiText4 As NotesRichTextItem
Dim rtiBody As NotesRichTextItem
Dim nrts As NotesRichTextStyle
Dim nrtsbold As NotesRichTextStyle
Dim strMsg As String
Dim docloop As Integer
Dim doc As New NotesDocument(s.CurrentDatabase)
Dim ndoc As NotesDocument
Dim Debug As Integer
Const LOGNAME = "NewWeeklyNewsletterwithlist(S)"
Dim Unid As String
Dim codedb As NotesDatabase
Dim codeview As NotesView
Dim notifdoc As NotesDocument
Dim item As NotesItem
Dim att1 As Variant
Dim st As Variant
Dim samplist List As String
server = s.CurrentDatabase.Server
Set codeview = codedb.GetView("Notification")
Set notifdoc = codeview.GetDocumentByKey("SampNotification")
st = Attention Set Item =
doc.ReplaceItemValue("OrigShipTo",Attention)
If notifdoc.DebugMode(0) = "1" Then
Set item = notifdoc.GetFirstItem("DebugEmail")
Att1 = item.Values st = att1 debug = True Else
debug = False End If
If (Not debug) And (Attention(0) ="") Then
Exit Sub
End If
Set rtiText1 = New NotesRichTextItem(doc, "Title1")
Set rtiText4 = New NotesRichTextItem(doc, "Title4")
Set rtiBody = New NotesRichTextItem(doc, "Body")
Set nrtsbold = s.CreateRichTextStyle
Set nrts = s.CreateRichTextStyle nrtsbold.NotesFont = Font_Helv
nrtsbold.FontSize = 10
nrtsbold.NotesColor = Color_Dark_Blue
nrtsbold.Bold = True
Call rtiText1.AppendStyle(nrtsbold)
Call rtiText4.AppendStyle(nrtsbold)
nrtsbold.FontSize = 8
Call rtiText1.AddNewLine(2)
Call rtiText1.AppendText(strMsg)
Call rtiText1.AddNewLine(2)
nrts.NotesFont = Font_Helv
nrts.FontSize = 8
nrts.NotesColor = Color_Black
nrts.Bold = False
Forall e In samplist
REM parse out each value
E1 = Strtoken(e,"~",1,5)
E2 = Strtoken(e,"~",2,5)
E3 = Strtoken(e,"~",3,5)
E4 = Strtoken(e,"~",4,5)
E5 = Strtoken(e,"~",5,5)
E6 = Strtoken(e,"~",6,5)
End Forall
Call rtiBody.AppendStyle(nrts)
docloop = 0
Set ndoc = dc.GetFirstDocument
While Not ndoc Is Nothing
docloop = docloop + 1
Call rtiBody.AppendText(Str$(docloop) & " - ( ")
Unid = ndoc.UniversalID strMsg = "An Error has occurred for a Lotus Database"
Call rtiBody.AppendDocLink(ndoc, strMsg)
Call rtiBody.AppendText(" ) ")
Call AgentLogAction(LOGNAME, "Loc" & Cstr(ndoc.LocationNumber(0)) & "PassThru: " & Cstr(nrts.PassThruHTML))
strmsg = ""
Select Case Action
Case "ErrorAlert"
Call rtiBody.AppendStyle(nrtsbold)
Call rtiBody.AppendText("Database name of Agent log: ") Call rtiBody.AppendStyle(nrts)
Call rtiBody.AppendText(ndoc.Location(0) & " " & ndoc.accountname(0))
Call rtiBody.AddNewLine(1)
Call rtiBody.AppendStyle(nrtsbold)
Call rtiBody.AppendText("Date/Time of Error: ")
Call rtiBody.AppendStyle(nrts)
Call rtiBody.AppendText(ndoc.OriginatorsName(0) )
Call rtiBody.AddNewLine(1)
Call rtiBody.AppendStyle(nrtsbold)
Call rtiBody.AppendText("Agent: ")
Call rtiBody.AppendStyle(nrts)
Call rtiBody.AppendText(ndoc.viewstatus(0) ) Call rtiBody.AddNewLine(1)
Call rtiBody.AppendStyle(nrtsbold)
Call rtiBody.AppendText("User Name: ")
Call rtiBody.AppendStyle(nrts)
Call rtiBody.AppendText(ndoc.ageinstatus(0) )
Call rtiBody.AddNewLine(1)
Call rtiBody.AppendStyle(nrtsbold)
Call rtiBody.AppendText("Error Message: ")
Call rtiBody.AppendStyle(nrts)
Call rtiBody.AppendText(ndoc.ageinstatus(0) )
Call rtiBody.AddNewLine(1)
Case "Confirm"
End Select
Set ndoc= dc.GetNextDocument(ndoc)
Wend
'Set up and Send Memo
doc.Form = "ReadyMemo"
Select Case Action
Case
"ErrorAlert"
strMsg = "An Error has occured in the following database" Call rtiText1.AppendText( GetKWV(" LogDatabases"))
Call rtiText1.AddNewLine(2)
End Select
("Principal")
doc.Subject = strmsg
doc.OrigST = Attention 'for debugging
doc.Principal = "Error Notifications"
doc.Save True, False
Call doc.Send(True, st)
Exit Sub
ProcessError:
Call AgentLogError(LOGNAME, 0, "NoteID: " & ndoc.NoteID & Err() & ": " & Error() & " Line: " & Erl() )
Msgbox Err() & ":" & Error() Resume Next End Sub
Software/Hardware used:
Domino 7.0