Folder Action Script only runs twice

No matter what I try, this folder action script will only run twice before ceasing to function.

Using my trusty Brother printer/scanner, I load up the feeder with copies of paper invoices that have been mailed to me. The goal is to scan the invoices, open a copy of the scan so I can read it and input a PO number, then save a local copy with the PO number to reference in the filename, and finally emailing a copy off to the bookkeeper.

The script works fine with 1 or 2 invoices. On 3 it craps out: the Preview window does not close, the email message is generated, but the scan is not attached, and the script stops processing altogether.

To experiment, I’m simply moving files in and out of the “ToSend” folder. The scanner software scans all the loaded documents, and deposits them all at once in that same folder.

Any assistance is truly appreciated.

on adding folder items to this_folder after receiving these_items
	set MyDay to day of (current date)
	set MyYr to year of (current date)
	set MyMo to month of (current date) as integer
	set BeckySent to "" & (path to desktop) & "BeckyInvoices:Sent"
	set BeckyToSend to "" & (path to desktop) & "BeckyInvoices:ToSend"
	set BeckyEmail to "Becky the Bookkeeper <>"

	repeat with this_item in these_items
			tell application "Finder"
				open file this_item
				tell application "System Events"
					set MyPONum to the text returned of (display dialog "What's the PO Number for this Invoice?" default answer "XXX") as text
					set name of this_item to MyPONum & "_Inv.png" as string
				end tell
				delay 1
				tell application "Preview" to quit
				move this_item to folder BeckySent --replacing yes
			end tell
			tell application "Mail"
				--	activate
				set new_msg to make new outgoing message with properties {sender:"Big Promotions CS <>", subject:MyPONum & "_Inv.png - Sent on " & MyMo & "/" & MyDay & "/" & MyYr, visible:true, signature:none, content:"Invoice for " & MyPONum & " attached

				tell new_msg to make new to recipient at end of to recipients with properties {address:BeckyEmail}
				tell content of new_msg to make new attachment with properties {file name:this_item} at after last paragraph
				close new_msg saving yes
				--send new_msg
				--delay 5
			end tell
		on error error_message number error_number
			tell application "Finder"
				display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
			end tell
		end try
	end repeat
end adding folder items to

Model: MacBook Pro and Mac Mini
Browser: Safari 525.20
Operating System: Mac OS X (10.5)

It isn’t a good idea to change the names of files inside a folder with a folder action because the folder action will be called again for each file that gets changed. That can cause all kinds of unexpected problems. I’d move the file to another folder and rename it there.