I've been following this with great interest. However, I've got a problem. Quite often our clients send emails with folders as attachments. The folders with their contents show as a single attachment, but can't be saved using the FILE command. Is there any answer to this please?
set ptd to path to desktop
set newFolderName to "2012-09-26 162222Z"
set newFolderPath to (ptd & newFolderName) as text
tell application "Finder"
if not (exists folder newFolderPath) then (make new folder at ptd with properties {name:newFolderName})
end tell
set newFolderPath to newFolderPath as alias
tell application "Mail"
activate
set tempmessage to message 1 of mailbox "* items to shift"
set selected mailboxes of message viewers to mailbox "* items to shift"
set theSelectedMessage to message 1 of mailbox "* items to shift"
repeat with eachAttachment in theSelectedMessage's mail attachments
try
save eachAttachment in file (newFolderPath & (name of eachAttachment) as rich text)
on error errmsg
try
save eachAttachment as (newFolderPath & (name of eachAttachment) as rich text) --< tried this for folder, but crashed
on error errmsg
display dialog errmsg
end try
end try
end repeat
end tell