I’ve created the following agent to run in my mail file on the Before mail arrives event. However, I get the following message on the server console when I try to track down the fault:-
AMgr: Agent(‘Extract Files Test’ in ‘mail/PROBSON.NSF’) error message: Error creating product object
The code of my agent is as follows:-
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim view As NotesView
Dim rtitem As Variant
Dim fileCount As Integer
Set db = session.Currentdatabase
Set dc = db.UnprocessedDocuments
Const MAX = 1
For x = 1 To dc.Count
Set Doc = dc.GetNthDocument(x)
'...set value of doc...
If Doc.Form(0) = "Memo" Then
If Doc.HasItem("Body") Then
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
If Doc.HasEmbedded Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) And (o.FileSize > MAX)Then
Call o.ExtractFile("\\CwlNAS1\MarketPicts\" & o.name)
'Call o.Remove
Call doc.Save( True, True )
End If
End Forall
End If
End If
End If
End If
Next
End Sub
However, if I change the event to after mail arrives I get the same error. But if I leave the event to after mail arrives and run the agent from the Designer screen, the agent works.
I suppose the question is Why can’t I seem to get it to work automatically on the event, while it works OK run from the client.