Applescript Editor在电子邮件中输入文本

时间:2013-12-24 15:27:07

标签: macos email applescript

我想制作一个允许您发送电子邮件的Applescript程序。 我做了这个,但它不起作用。 谁能帮我吗?

代码:

set answer1 to text returned of (display dialog "Type here your message" default answer "" buttons {"OK"} default button 1)
set answer2 to text returned of (display dialog "Type the e-mail you want to send to" default answer "" buttons {"OK"} default button 1)
set answer3 to text returned of (display dialog "Type your subject" default answer "" buttons {"OK"} default button 1)
tell application "Mail"
    open "new"
    delay 1
    keystroke answer1
    tell application "System Events" to key code 48
    repeat 3 times
        keystroke answer3
        tell application "System Events" to key code 48
        keystroke answer2
        open "send"
    end repeat
end tell

希望你们中的任何人都能知道我能做些什么。

1 个答案:

答案 0 :(得分:0)

嗯,如上所述,'系统事件'不是要走的路。这是我认为你想要做的一种方法:

set answer1 to text returned of (display dialog "Type here your message" default answer "" buttons {"OK"} default button 1)
set answer2 to text returned of (display dialog "Type the e-mail you want to send to" default answer "" buttons {"OK"} default button 1)
set answer3 to text returned of (display dialog "Type your subject" default answer "" buttons {"OK"} default button 1)
tell application "Mail"
    set myMessage to make new outgoing message with properties {visible:true, subject:answer3, content:answer1}
    tell myMessage
        make new to recipient with properties {name:answer2, address:answer2}
        send
    end tell
end tell