Am 2008-08-25 um 23:44 schrieb has:

* issue (1) [appscript syntax for Mail.app]:
I can list the attachments with appscript, but I didn't find a way to save them or to access them as files.

Something like this should work (assuming the files don't already exist in the destination folder):

message = app('Mail').selection()[0]
for attachment in message.mail_attachments():
attachment.save(in_=mactypes.File(u'/path/to/outfolder/' + attachment.name()))

Thank you, that works.
Now I can drop my MIME attachment decoding.

Now I've finally the readable text of the message in proper unicode.
Let's make a reply mail:

reply = message.reply(opening_window=True)

I don't understand why usually a message window is invisible, but anyway, that works so far.

reply.content.set(decrypted_text)

Doesn't work: If I try it in PyCrust, the new text appears above the initial content, can't delete that.
In my script I get only a CommandError:

CommandError -10000: Apple event handler failed.
Failed command: app(u'/Applications/ Mail.app').outgoing_messages.ID(409455472).content.set(u'bla')

Despite that error, when I close Mail.app, a new message containing my text appears, i.e. instead of setting the content of my previously created reply mail, it makes a new outgoing message in the background.

* issue (4) [appscript syntax for Mail.app]:
How can I set the complete content of a reply message?

Dunno offhand; might have time to look into it tomorrow unless anyone else has any ideas. As you say, Mail's scripting interface is less than stellar. BTW, you could also try asking on Apple's AppleScript-users mailing list; I expect there's a few folk there who've had dealings with Mail as well and might be able to shed some light on the problem.


I found a blog entry that collects some of Mail.app's bugs, including this:
http://willwont.blogspot.com/2008/04/applescripting-mailapp.html

I also found a thread on an Apple list, where several guys tried to get replies working (and didn't) - strangely at one of them's machine it worked (but even there only after each other restart of Mail.app):
http://lists.apple.com/archives/applescript-users/2007/Jan/threads.html#00085

Remember I got it partly working from PyCrust, but not from my own script - there's a trick involved anywhere...

Here's another attempt:


reply = message.reply(opening_window=True)
reply.close(saving=k.no) # close useless reply

for m in mailapp.outgoing_messages():
        m.visible.set(True) # make hidden messages visible


I tried "everything", but didn't manage to set any outgoing_message's content or add a recipient.
I thought the following should work:

 reply.to_recipients.end.make(
        new=k.recipient,
                with_properties={
                        'address': message.sender.extract_address_from(),
                        'name': message.sender.extract_name_from()
                })
 reply.content.set(decrypted)


Now I just copy my content to the clipboard ( osax.ScriptingAddition.set_clipboard_to() ), so I can paste it as reply.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to