Worked with POP, doesn't work with IMAP

Hi folks,

Below is a script I’ve been using within a Hazel rule for a few years. It worked beautifully with a POP account. I’ve recently switched to using IMAP for the same account, and since then the script hasn’t worked.

The script:

tell application "Mail"
		activate
		set theMessage to message 1 of mailbox "Sent" of account "Mail.com" of application "Mail"
		set theSubject to subject of theMessage
		display dialog theSubject & "...  Save copy?" buttons {"No", "Yes"} default button 1
		if (button returned of the result) = "No" then
			set mailbox of theMessage to mailbox "Trash" of account "Mail.com" of application "Mail"
		end if
		set selected mailboxes of front message viewer to {sent mailbox}
		set selected mailboxes of front message viewer to {trash mailbox}
		set selected mailboxes of front message viewer to {inbox}
		display dialog "Continue with Mail?" buttons {"No", "Yes"} default button 1
		if (button returned of the result) = "No" then
			close front window
		end if
	end tell

Should I be using some different terms for IMAP? Or is there something else to try? Any help appreciated. (NB: I’m not much of geek with scripting etc, so please minimise the geekspeak in replying … )

Thanks.

Model: macbook2.16
AppleScript: 2.3
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)