Bit of a dilemma. When opening a mail message from a script, in Yosemite, most of the menu items remain greyed out.
I really, really need to use the GUI to save the mail attachments, as it’s no longer possible to use the method of selecting the attachments, then copying them and pasting into an rtfd document.
Would anyone know the answer to this problem, please? I’ve been trying for 5 hours, with no luck. Try the script below, in Script Editor, if you’s like to check it out.
I would really like feedback on this one, seems like a bug to me.
set MissingAction to true
tell application "Mail"
activate
set WindowCount to count of windows
open item 1 of messages of mailbox "* items to store"
set x to 0
repeat # wait until the message is really open.
tell current application to delay 0.1
set x to x + 1
if x > 40 then exit repeat
if (count of windows) > WindowCount then exit repeat
end repeat
tell application "System Events" to tell process "Mail"
tell current application to delay 0.2
keystroke "A" using command down
if exists menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1 then
say "attachments true” —< says ‘true’ even when menu not enabled
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
delay 10
set attachmentsExist to true
set x to 0
set MissingAction to false
repeat 10 times
try
click menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1
on error
exit repeat
end try
end repeat
repeat until exists sheet 1 of window 1
tell current application to delay 0.1
set x to x + 1
if x = 40 then
set MissingAction to false
exit repeat
end if
end repeat
end if
end tell
end tell
MissingAction