Save attachments agent - variable not set

Hi,

I’m not a developer so I’m having a hell of a time working out why this script wont run. Any help would be greatly appreciated…

Sub Initialize

Dim session As New NotesSession



Dim db As NotesDatabase	



Dim doc As NotesDocument



Dim rtitem As Variant



Dim fileCount As Integer



Dim view As NotesView



Const MAX = 1000



fileCount = 0    



'set db

Set db = session.CurrentDatabase



'set view

Set view = db.GetView( "viewName" )

'…set value of doc…

Set doc = view.getfirstdocument



Do Until doc Is Nothing

	

	

	Set rtitem = doc.GetFirstItem( "Body" )

	

	If ( rtitem.Type = RICHTEXT ) Then

		

		Forall o In rtitem.EmbeddedObjects

			

			If ( o.Type = EMBED_ATTACHMENT ) _ 

			And ( o.FileSize > MAX ) Then

				

				fileCount = fileCount + 1

				

				Call o.ExtractFile _

				( "c:\reports\newfile" & Cstr(fileCount) )

				

				Call doc.Save( True, True )

				

				

			End If

			

		End Forall

		

	End If

	Set doc = view.GetNextDocument( doc )

	

Loop

End Sub

Subject: save attachments agent - variable not set

Not being a developer doesn’t make this easy at all, but… I will try:

  1. is there a view in your database called “viewName”?

  2. does this view contain only documents with a richtext field called “Body”?