[Pythonmac-SIG] AppleEvent

Francois Granger fgranger@altern.org
Wed, 25 Sep 2002 17:44:08 +0200


I am trying some AppleEvent in Python (v2.2.1 on MacOS 9.1). Basically, I
want to iterate throught all the messages in one folder, and get some items
of each message such as 'From', 'Received: ...

I tested the following AppleScript with ScriptEditor

tell application "Microsoft Entourage"
    set theList to messages of folder "Spam"
    repeat with m in theList
        set txt to headers of m
    end repeat
end tell

I am now trying to convert it to Python. I read the doc. Created the
Entourage folder inside the lib-Scriptpackabes folder. I read th archives o=
f
the list, no idea how to do it.

Id did the simple test code:

import Entourage
#talker =3D Entourage.Entourage()
#talker.activate()
fld =3D Entourage.folder("Spam")
wnd =3D Entourage.windows(fld)
#messlist =3D wnd.content()
messlist =3D Entourage.current_messages(fld)
#messlist =3D talker.get(Entourage.message(fld))
for mess in messlist:
    headers =3D mess.headers()


1) With line 2 and 3 uncommented I get the following traceback.

Traceback (most recent call last):
  File "Macintosh HD:Dev:spam:asentourage.py", line 3, in ?
    talker.activate()
  File "Macintosh HD:Python 2.2:Mac:Lib:aetools.py", line 195, in activate
    self.send('misc', 'actv')
  File "Macintosh HD:Python
2.2:Mac:Lib:lib-scriptpackages:Entourage:Entourage_Mail_and_News_Sui.py",
line 53, in send
    _arguments, _attributes)
TypeError: send() takes at most 3 arguments (5 given)

2) Line 7 give me a proper object, not iterable.
I tried a lot of other combination, but I guess I did understood nothing to
what was recently discussed about verbs and attributes ;-)
--=20
Fran=E7ois Granger
fgranger@altern.org