Agent from button to Schedule

I have an agent that detaches email attachments to a shared drive that works from a button perfectly. I need it to work as a scheduled agent that runs once a day. I’ve modified the agent Trigger and Target and can’t get it to work. I am not very good with Lotus Script and have limited experience with LS agents.

The code is below. Thanks

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim rtitem As Variant





Set db = session.CurrentDatabase

Set collection = db.unprocessedDocument

set doc = collection.GetFirstDocument()



While Not(doc is Nothing)

	set rtitem = doc.GetFirstItem("Body")

	If (rtitem.Type = RICHTEXT) Then

		Forall o In rtitem.EmbeddedObjects

			If (o.Type = EMBED_ATTACHMENT) Then

				Call o.ExtractFile("c:\TEMP\" & o.Source)

			End If

		End Forall

	End If

	Set doc = collection.GetNextDocument(doc)

Wend

End Sub

Subject: Agent from button to Schedule

If it works in the client and not when it’s scheduled, it may be the agent security. I think file IO may be restricted on the server. In the security tab of the agent is it set to “Allow Restricted Operations”?

Subject: Agent from button to Schedule

Will this agent be scheduled locally? Or on the server?

If it is the server…

then the signer of the agent must have access to run unrestricted agents on the server. Also check your read/write permissions on the directory that you are writing to. Lastly, on the agent properties, check the security tab and set the runtime security level to 2. Allow Restricted Operations.

If it is running locally…

then realize that it will only run while the Notes client is open. Also check the runtime security level mentioned above.

Good luck!