I am running a Lotusscript Agent on "Before mail arrives". I need it to grab the text in the subject line after the "#" symbol. No matter how I try to get the Subject field (Evaluate, getFirstItem, getItemValue, etc), I always end up with an error. Usually it is a type mismatch or object variable not set.
The code below is my current code and returns an error 13 on line 14 "type mismatch"
Option Public
Option Declare
Sub Initialize
On Error GoTo ErrorHandler
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesDocumentCollection
Dim doc As NotesDocument
Dim nextdoc As NotesDocument
Dim result As String
Set db = s.CurrentDatabase
Set view = db.Unprocesseddocuments
If Not view Is Nothing Then
Set doc = view.Getfirstdocument()
While Not doc Is Nothing
result = Evaluate ("@Right(Subject;""#"")", doc)
Print result
Set nextDoc = view.GetNextDocument(doc)
Call doc.Remove(True)
Set doc = nextDoc
Wend
End If
Print "End"
Done:
Exit Sub
ErrorHandler:
Select Case Err
Case Else
Print "Error " & CStr(Err) & " in agent on line " & CStr(Erl) & ": " & Error
Resume Done
End Select
End Sub