Watch Entourage for new mail

I want to build a script that will watch Entourage, and when new mail comes in, save the attachment, then delete the mail. There is a lot more to the script than I have described here but I have the rest down. I have been looking at the dictionary but am at a bit of a loss. Could anybody put me on the right path?
Thanks.
Jake Norris

Surely this could be done directly from entourage. using the rules settings.

To a point, yes you can. What I am trying to achieve is mostly possible with rules, but I require that the attachments be saved into a different folder each week defined in part by name and in part by numeric index(something I have been struggling to master also). Is there a way of achieving this with rules to achieve the outcome desired, or a combination of rules and applescript?
Jake

I’ve got this, its working nice for me, think I have found at least the base to it (if not the whole script) here on MacScripter:

tell application "Microsoft Entourage"
	set selectedMsg to (current messages)
	set selectedMsg to item 1 of result
	
	
	repeat with i from 1 to count of attachments in selectedMsg
		
		set msgAttachment to attachments of selectedMsg
		set msgAttachment to result's item i
		
		set attachmentName to name of msgAttachment
		
		set attachmentFile to ("Path:To:Folder" & attachmentName) as text
		
		--> save message to disk before we open it
		save msgAttachment in attachmentFile
		
	end repeat
	
	tell application "Finder"
		open folder "Path:To:Folder"
		set frontmost to true
	end tell
	
end tell

Regards
Johan

Can you not point the rule at the applescript (when new mail arrives run script)

Hmmm, yes… thats what I do with my script, I might have missunderstood the question…

The rule does the watching.
Then calls the script.

Rather than a Script does the watching and saving to folders.