Hi,
I am trying to create an Agent that saves attachments of incoming mail automatically into a given folder on the Notes Server. I currently have the following code.
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set col = db.UnprocessedDocuments
If col.Count <> 0 Then
Set doc = col.GetFirstDocument
Do While Not( doc Is Nothing )
Set rtitem = doc.GetFirstItem( "Body" )
If (rtItem.Type = RICHTEXT) Then
Forall o In rtitem.EmbeddedObjects
fileCount = fileCount + 1
If (o.Type = EMBED_ATTACHMENT) Then Call o.ExtractFile _
("\\10.139.1.15\sourcing\" & o.Name)
Call o.Remove
Call doc.Save( True, True )
End Forall
End If
Call session.UpdateProcessedDoc( doc )
Set doc = col.GetNextDocument(doc)
Loop
End If
End Sub
This works great if I set the Agent to an Action Menu Selection and to Selected Documents. However if I set it to On Schedule and New & Modified Documents it fails with the Error “Type Mismatch”. I don’t know which line is causing the error.
Can anyone shed any light on this?
Thanks in advance.