Agent Issue

i have written an agent .When u run manually it is working.While running on server the agent stopped at a particular line. this is the code .

Agent properties:After a new mail has arrived.

it is not working after this line Set view1=db.GetView(“(LUMail Groups)”)

pls help…

Sub Initialize

Dim session As New Notessession

'Dim ws As New NotesUIWorkspace

Dim  db As Notesdatabase

Dim  db1 As Notesdatabase

Dim doce1 As NotesDocument

Dim doc As Notesdocument

Dim collection As NotesViewEntryCollection

Dim entry As NotesViewEntry

Dim doc1,doce As Notesdocument

Dim profiledoc As Notesdocument

Dim members As notesitem

Dim doccollect As NotesDocumentCollection

Dim dc2 As NotesDocument   '

Dim dmeview1 As NotesDocument 

Dim rtitem As NotesRichTextItem

Dim server1 As String

Dim path1 As String

Dim folderview As NotesView	

Dim view As NotesView	

Dim view1 As NotesView

Dim view2 As NotesView

Dim view3 As NotesView

Dim dmeview As NotesDocumentCollection 

Set db1 = session.CurrentDatabase

server1="CN=Green/O=IBS"

path="SSLOB01.nsf"

Set db = session.Getdatabase(server1 , path)

Set folderview = db1.GetView("SSLOB Unsubscribe")

Set view = db.GetView("Mail Groups")

Set view1=db.GetView("(LUMail Groups)")

Set view2=db.GetView("(LUMember Information2)")

Set view3=db.GetView("(LUMember Information2)")

Set doc2=view.getfirstdocument

Set foldervc = folderview.AllEntries

Set doc = folderview .GetFirstDocument

Dim str2 As String 

While Not doc Is Nothing

	Set docf = folderview.GetNextDocument(doc)

	If doc.INetFrom(0) ="" Then

		str2=doc.From(0)

		Set doc3=view3.GetDocumentByKey(doc.From(0),True)

	Else

		str2=doc.INetFrom(0)

		Set doc3=view3.GetDocumentByKey(doc.INetFrom(0),True)

	End If

	

	While Not doc2 Is Nothing

		textList = doc2.GetItemValue("GroupMembers_1")

		textList2 = doc2.GetItemValue("GroupMembers")

		For i = 0 To Ubound(textList)    

			If doc.INetFrom(0) ="" Then

				key=	doc.From(0)

			Else

				key=  doc.INetFrom(0)

			End If

			

			key1=  Lcase(textList(i))

			key3=textList2(i)

			key2=Lcase(textList2(i))

			doc2.NewGroupMembers="" 

			doc2.UpdatedNames="" 

			Set item4=doc2.GetFirstItem("NewGroupMembers" )	

			Set item5=doc2.GetFirstItem("UpdatedNames" )	

			If Strcompare(key1, key) =0 Then

			Else

				item4.AppendToTextList(key1)

				item5.AppendToTextList(key3)

			End If

		Next

		doc2.GroupMembers_1=doc2.NewGroupMembers 'Replacing the email id's with modified

		doc2.NewGroupMembers=""

		doc2.GroupMembers=doc2.UpdatedNames 'Replacing the email id's with modified

		doc2.UpdatedNames="" 

		Call doc2.Save(True,False)			

		Set doc2 = view.GetNextDocument(doc2)          

	Wend  'End doc2

	Call doc.Remove (True)

	Set doc=docf

'	Call view.Refresh

Wend    'End doc

Set view1=db.GetView("(LUMail Groups)")

Call view1.refresh

Set collection = view1.AllEntries

Set entry = collection.GetFirstEntry()

While Not(entry Is Nothing)

	Set doce1 = entry.Document

	doce1.Remove(True)

	Set entry = collection.GetNextEntry(entry)

Wend

’ Set dview1=view1.GetFirstDocument

’ While Not dview1 Is Nothing

’ Set dview2=view1.GetNextDocument(dview1)

’ Call dview1.remove(True)

’ Call view1.Refresh

’ Set dview1=dview2

’ Wend

Set view3=db.GetView("(LUMember Information2)")

Call view3.refresh

Set dmeview=view3.GetAllDocumentsByKey(str2)

Set dmeview1=dmeview.GetFirstDocument 

While Not dmeview1 Is Nothing

	Set dmeview2=dmeview.GetNextDocument(dmeview1)

	Call dmeview1.remove(True)

	Set dmeview1= dmeview2

	Call view3.Refresh

Wend

End Sub

Subject: On Error Goto label

Show a better error message using “On Error”

Something like this:

Sub Initialize

On Error Goto label

Exit Sub

label:

Msgbox "Error: "+Error()+" Line: "+Cstr(Erl)

Exit Sub

End Sub

Subject: RE: On Error Goto label

Thanks for your help.Identified error using On rror & solved the issue