Run Agent Before/After Mail Arrived

Hi AllTo All Woman : Happy Woman’s Day

I Have to Run an agent Either After New mail arrived or before new mail arrived in my mail box. The code is working fine when i run it through action menu but it is not working After New mail arrived or before new mail arrived. IM sending my code just go through it :

===============================================

Dim workspace As New NotesUIWorkspace

Dim s As New notessession

Dim db,db1 As notesdatabase

Dim doc,doc1 As notesdocument

Dim vw,vw1 As NotesView

Dim doc2 As NotesDocumentCollection

Set db = s.CurrentDatabase

Set vw1 = db.getview(“($All)”)

Set db1=s.GetDatabase(“v2solutions”,“AttachDo.nsf”)

Set doc=vw1.GetFirstDocument

Set vw = db1.GetView(“v2_ProfileView”)

While Not doc Is Nothing

c=0

Mail_Id=doc.principal(0)

Set doc2 = vw.GetAllDocumentsByKey(Mail_Id)

x = doc2.Count

If x =< 0 Then

Set doc1= doc

Call doc1.remove(True)

Call vw1.Refresh

Call workspace.ViewRefresh

c=1

End If

If c=1 Then

Set doc=vw1.GetFirstDocument

Else

Set doc=vw1.GetNextDocument(doc)

End If

Wend

=============================================

Sanjay Prasad

Subject: Run Agent Before/After Mail Arrived

Hello,

If the agent is running ok when run manually, that implies its a problem with the schedule or access settings rather than the script.

Check what server it is set to run on, and ensure that the ID that saved the agent has the privileges to run agents on the server.

Good luck,

Katherine.

Subject: RE: Run Agent Before/After Mail Arrived

Hi KatherineThanx 4 response

I tried as u said, agent is firing but in server console this error is showing…

===========================================

03/08/2005 02:44:55 PM AMgr: Agent (‘v2_agt_Mail’ in ‘mail\sprasad.nsf’) error message: Error creating product object

===========================================

Pls. guide me

Sanjay prasad

Subject: Run Agent Before/After Mail Arrived

You can’t use UI objects in a background agent.

Subject: RE: Run Agent Before/After Mail Arrived

Hi Howard

Thank you very much now it is working fine.

Regards

Sanjay