Py-appscript:如何使用Mail.app发送消息

时间:2010-07-02 13:41:13

标签: python applescript

我正在尝试使用py-appscript创建邮件(python的AppleScript界面​​)。 我尝试了以下代码,

from appscript import *

mail = app('Mail')
msg = mail.make(new=k.outgoing_message,
                with_properties={'visible':True,
                                 'content':"hello",
                                 'subject':"appscript",
                                 'sender':'taichino@gmail.com'
                                 })

但收到以下错误消息,我找不到任何相关信息......

CommandError: Command failed:
  OSERROR: -1701
  MESSAGE: Some parameter is missing for command.
  COMMAND: app(u'/Applications/Mail.app').make('outgoing_message', with_properties={'content': 'hello', 'visible': True, 'sender': 'taichino@gmail.com', 'subject': 'appscript'})

建议,拜托?

1 个答案:

答案 0 :(得分:0)

自己解决了问题,以下代码运行正常。

from appscript import *

mail = app('Mail')
msg = mail.make(new=k.outgoing_message)
msg.subject.set("hello"),
msg.content.set("appscript")
msg.to_recipients.end.make(new=k.to_recipient, with_properties={'address':'taichino@gmail.com'})
msg.send()

不是在构造函数中设置属性,而是单独设置每个属性。

相关问题