Save attachments Apple Script for Mail in Lion
Hello,
The script below has been superb for us as we need attachments that come in from specific people to be saved automatically to a folder. We then have a series of Folder Actions that take care of things thereafter.
However since upgrading to Lion this script doens't seem to work. I know a few others are having problems and wondered if this is a bug with Lion or if the changes in mail mean that this script needs re-worked. Any help would be great!
using terms from application "Mail" -----bij mail rule aanzetten
on perform mail action with messagestheMessagesfor ruletheRule-----bij mail rule aanzetten
--set theOutputFolder to (here's where you tell it the main folder to save in)
tell application "Finder"
set theOutputFolder to folder "MACHD:Users:Pinstripe:Desktop:Incoming"
end tell
tell application "Mail"
--comment the following line when running this script as a Mail.app rule function - uncomment it for testing
--set theMessages to selection --------bij testen aanzetten
repeat with theMessage in theMessages
--does the message have attachments? if not, then skip it
if (every mail attachment of theMessage) ≠ {} then
--save the attachment to the subfolder
set theAttachments to (every mail attachment of theMessage)
repeat with theAttachment in theAttachments
set thePath to (theOutputFolder as string) & (name of theAttachment)
--if same named file already exists in subfolder, skip it
if not (exists (alias thePath of application "Finder")) then
savetheAttachmentinthePath
end if
end repeat
set read status of theMessage to true
end if
end repeat
end tell
end perform mail action with messages
end using terms from
iMac, Mac OS X (10.7)