I'm new to applescript and I'm having enormous trouble doing something which seems very basic. I'm trying to save a selected mail message in RTF format with attachments. Here is the errant script:
tell application "Mail"
activate
set AllMessages to selection
set myMessage to item 1 of AllMessages
open myMessage
tell application "System Events"
tell process "Mail"
tell menu bar 1
tell menu bar item "File"
tell menu "File"
click menu item "Save As…"
delay 2
keystroke "test"
click checkbox "Include Attachments" -- result: ERROR
end tell
end tell
end tell
end tell
end tell
end tell
You can try something like this:
set the clipboard to POSIX path of (path to desktop as text) & "test"
tell application "Mail"
open first item of (get selection)
activate
end tell
tell application "System Events"
tell process "Mail"
click menu item "Save As…" of menu 1 of menu bar item "File" of menu bar 1
delay 3
perform action "AXPress" of pop up button 1 of group 1 of sheet 1 of window 1
click menu item 1 of menu 1 of pop up button 1 of group 1 of sheet 1 of window 1
if value of checkbox "Include Attachments" of group 1 of sheet 1 of window 1 = 0 then
perform action "AXPress" of checkbox "Include Attachments" of group 1 of sheet 1 of window 1
end if
keystroke "g" using {command down, shift down}
keystroke "v" using {command down}
keystroke return
keystroke return
end tell
end tell
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.