【问题标题】:AppleScript to attach photo to end of open Mail messageAppleScript 将照片附加到打开的邮件消息的末尾
【发布时间】:2013-05-05 22:57:41
【问题描述】:

2012 年 12 月,这个 stackoverflow 网站的 Mark Hunte 通过提供以下 AppleScript 帮助了另一个用户。该脚本创建一个新的电子邮件消息。并在末尾附加一个文件。

这里有人可以帮助我吗?我需要这个脚本的缩短版本,它只做一件事:将名为“selectedPhoto.jpg”的文件附加到已打开电子邮件的末尾。

也就是说,如果我正在创建新电子邮件或回复电子邮件并且已经打开了窗口,我想运行一个脚本,该脚本只是将照片附加到该电子邮件的末尾。

我已尝试删除以下脚本的行,但无法使其正常工作。

我正在运行 OS X 10.8

有人可以帮忙吗?


set theAttachment1 to POSIX file "/Users/USERNAME/Desktop/Desktop--IMAGE/scooter-6.jpg"

tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"subject", content:"the_content" & return & return}
    tell newMessage

        set visible to false
        set sender to "myaddress@btinternet.com"
        make new to recipient at end of to recipients with properties {address:"someAddress@btinternet.com"}
        make new attachment with properties {file name:theAttachment1} at after the last paragraph

        (* change save to send to send*)
        save --<<<<---------------- change save to send to send
        (* change save to send to send*)
    end tell
end tell

【问题讨论】:

    标签: email applescript


    【解决方案1】:

    我无法让tell outgoing message 1 to make new attachment 工作,但您可以使用 UI 脚本:

    set old to the clipboard as record
    set f to "/Library/Desktop Pictures/Antelope Canyon.jpg"
    set the clipboard to (read (POSIX file f as alias) as JPEG picture)
    activate application "Mail"
    tell application "System Events" to keystroke "v" using command down
    set the clipboard to old
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多