Duplicate Emails by attachment name

Hello!
I have a special need, in that I receive several copies of news releases each day. They are actually the same in content and attachment, but are mailed to individual email boxes, based on the home of the people mentioned in the email. Since I process them automatically, I capture all states in one mailbox.

 Currently, I use an applescript from public domain that tests for unique message ID.  it looks like this:  

-- Remove Duplicate Message v1.0

tell application "Microsoft Entourage"
	set theMessages to current messages
	if theMessages = {} then
		set theFolder to selection
		if class of theFolder is folder then
			set mb to theFolder
		else
			display dialog "In the folder listing, please select the folder you want to be scanned for duplicates" with icon stop buttons {"Quit"} default button 1
			return -99
		end if
	else
		set mb to storage of item 1 of theMessages
	end if
	set theName to name of mb
	say "Removing duplicates from mail folder: " & theName
	set y to count messages of mb
	say "Number of messages to check, " & y
	set IDlist to {}
	repeat with X from y to 1 by -1
		try
			set theHeaders to (get headers of message X of mb)
			set AppleScript's text item delimiters to {"Message-"}
			set temp to text item 2 of theHeaders
			set AppleScript's text item delimiters to {return}
			set theID to text 5 through -1 of text item 1 of temp
		on error
			set theID to ""
		end try
		if theID is in my IDlist then
			delete message X of mb
		else if theID ≠ "" then
			copy theID to end of IDlist
		end if
		if X mod 100 = 0 then say "" & X
	end repeat
	set removedCount to y - (count messages of mb)
	if removedCount is 0 then
		say "Finished. No duplicates detected"
	else
		say "Finished. " & removedCount & " duplicates removed"
	end if
	set AppleScript's text item delimiters to {""}
end tell

Can anyone give me guidance on how to check ATTACHMENT NAME rather than message ID?

I greatly appreciate it!

TIger

Hi Tiger

something along the lines of this should do it

tell application "Microsoft Entourage"
	set theMessages to item 1 of (get current messages)
	set theAttachment to name of attachment 1 of theMessages
	display dialog theAttachment as text
end tell