简体   繁体   English

在AppleScript中保存邮件

[英]Saving a mail message in applescript

I'm new to applescript and I'm having enormous trouble doing something which seems very basic. 我是applescript的新手,在做一些看起来很基础的事情时遇到了很大的麻烦。 I'm trying to save a selected mail message in RTF format with attachments. 我正在尝试将选定的邮件保存为带有附件的RTF格式。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM