views:

29

answers:

1

I'm trying to create mail with py-appscript (AppleScript interface for python). I tried following code,

from appscript import *

mail = app('Mail')
msg = mail.make(new=k.outgoing_message,
                with_properties={'visible':True,
                                 'content':"hello",
                                 'subject':"appscript",
                                 'sender':'[email protected]'
                                 })

but got following error messages, and I couldn't find out any information for that...

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': '[email protected]', 'subject': 'appscript'})

Suggestions, please?

A: 

Problem solved by myself, following code works fine.

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':'[email protected]'})
msg.send()

Insted of setting properties in constructor, set each property separately.

taichino
Setting properties via the `make` command should work. However, you need to use keyword objects, not strings, as your keys: `{k.visible:True, k.content:...}`. Scriptable apps generally don't recognize string-based keys in records. See ch. 6 of the appscript manual for more info.
has
Thank you very much! I checked it works great!This is what I wanted to know.
taichino