开发者

Py-appscript: How to configure mail created by reply()

开发者 https://www.devze.com 2023-01-05 11:13 出处:网络
I\'m trying to reply to a mail in Mail.app with py-appscript. I tried the code below, from appscript import *

I'm trying to reply to a mail in Mail.app with py-appscript.

I tried the code below,

from appscript import *

mailapp = app('Mail')

# get mail to be replied
msg = mailapp.accounts.first.mailboxes.first.messages.first

# create reply mail
reply_msg = mailapp.reply(msg)

# set mail (got error)
reply_msg.visible.set(True)
reply_msg.subject.set('replied message')
reply_msg.conten开发者_JS百科t.set('some content')

but got following error, it failed to set subject. (setting visible property is succeeded)

CommandError: Command failed:
        OSERROR: -10000
        MESSAGE: Apple event handler failed.
        COMMAND: app(u'/Applications/Mail.app').outgoing_messages.ID(465702416).subject.set('replied message')

It works when I use "make" instead of "reply" to create new message.

# create new mail
msg = mailapp.make(new=k.outgoing_message)

# set mail (works fine)
msg.visible.set(True)
msg.subject.set('new mail')
msg.content.set('some content')

Can you please tell me what this error is and how to fix it?


Works fine on 10.6 but there's a bug in Mail on 10.5 (and probably earlier) that causes outgoing messages created by the reply command not to work correctly.

If you have to support 10.5, I think your only option is to build a new outgoing message from scratch, copying the relevant information from the message you're replying to yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消