Python and MAPI

Michel Orengo michelorengo at netscape.com
Wed Jan 19 15:52:30 EST 2000


Grant Edwards wrote:

> OK, I did that with msoutlk85.olb.  I'm assuming that a message
> object is of type _MailItem.  I've got a big list of properties
> and methods that _might_ work, but how do you find out which
> ones are implimented by a particular object?
>
> For example, the messages in my inbox implement properties
> "Subject" and "Size", but not "Body", "To", or "SenderName".
> I guess I could iterate the the properties dictionary and try
> all of them...

Well, here is an extract of the file produced by makepy (under gen_py):
- BTW, I selected the "OLE/Messaging 1.0 Object Library" not sure what is the
msoutlk85.olb.-

class Message(DispatchBaseClass):
 """OLE/Messaging Message"""
 CLSID = pythoncom.MakeIID('{3FA7DEAA-6438-101B-ACC1-00AA00423326}')

 def Delete(self):
  """ """
  return self._ApplyTypes_(0x6a, 1, (12, 0), (), 'Delete', None)

 def Options(self, parentWindow=defaultNamedOptArg):
  """ """
  return self._ApplyTypes_(0x7d, 1, (12, 0), ((12, 17),), 'Options', None,
parentWindow)

 def Send(self, saveCopy=defaultNamedOptArg, showDialog=defaultNamedOptArg,
parentWindow=defaultNamedOptArg):
  """ """
  return self._ApplyTypes_(0x83, 1, (12, 0), ((12, 17), (12, 17), (12, 17)),
'Send', None, saveCopy, showDialog, parentWindow)

 def Update(self, makePermanent=defaultNamedOptArg,
refreshObject=defaultNamedOptArg):
  """ """
  return self._ApplyTypes_(0x84, 1, (12, 0), ((12, 17), (12, 17)), 'Update',
None, makePermanent, refreshObject)

 _prop_map_get_ = {
  "Application": (20, 2, (12, 0), (), "Application", None),
  "Attachments": (5, 2, (12, 0), (), "Attachments", None),
  "Class": (6, 2, (12, 0), (), "Class", None),
  "Conversation": (8, 2, (12, 0), (), "Conversation", None),
  "ConversationIndex": (55, 2, (12, 0), (), "ConversationIndex", None),
  "ConversationTopic": (54, 2, (12, 0), (), "ConversationTopic", None),
  "DeliveryReceipt": (50, 2, (12, 0), (), "DeliveryReceipt", None),
  "Encrypted": (10, 2, (12, 0), (), "Encrypted", None),
  "Fields": (12, 2, (12, 0), (), "Fields", None),
  "ID": (14, 2, (12, 0), (), "ID", None),
  "MAPIOBJECT": (49, 2, (12, 0), (), "MAPIOBJECT", None),
  "Parent": (25, 2, (12, 0), (), "Parent", None),
  "ReadReceipt": (30, 2, (12, 0), (), "ReadReceipt", None),
  "Recipients": (28, 2, (12, 0), (), "Recipients", None),
  "Sender": (32, 2, (12, 0), (), "Sender", None),
  "Sent": (33, 2, (12, 0), (), "Sent", None),
  "Session": (34, 2, (12, 0), (), "Session", None),
  "Signed": (35, 2, (12, 0), (), "Signed", None),
  "Size": (36, 2, (12, 0), (), "Size", None),
  "Submitted": (18, 2, (12, 0), (), "Submitted", None),
  "TimeReceived": (40, 2, (12, 0), (), "TimeReceived", None),
  "TimeSent": (41, 2, (12, 0), (), "TimeSent", None),
  "Unread": (42, 2, (12, 0), (), "Unread", None),
  "folderID": (51, 2, (12, 0), (), "folderID", None),
  "importance": (27, 2, (12, 0), (), "importance", None),
  "storeID": (52, 2, (12, 0), (), "storeID", None),
  "subject": (38, 2, (12, 0), (), "subject", None),
  "text": (39, 2, (12, 0), (), "text", None),
  "type": (17, 2, (12, 0), (), "type", None),
 }
 _prop_map_put_ = {
  "Application" : ((20, LCID, 4, 0),()),
  "Attachments" : ((5, LCID, 4, 0),()),
  "Class" : ((6, LCID, 4, 0),()),
  "Conversation" : ((8, LCID, 4, 0),()),
  "ConversationIndex" : ((55, LCID, 4, 0),()),
  "ConversationTopic" : ((54, LCID, 4, 0),()),
  "DeliveryReceipt" : ((50, LCID, 4, 0),()),
  "Encrypted" : ((10, LCID, 4, 0),()),
  "Fields" : ((12, LCID, 4, 0),()),
  "ID" : ((14, LCID, 4, 0),()),
  "MAPIOBJECT" : ((49, LCID, 4, 0),()),
  "Parent" : ((25, LCID, 4, 0),()),
  "ReadReceipt" : ((30, LCID, 4, 0),()),
  "Recipients" : ((28, LCID, 4, 0),()),
  "Sender" : ((32, LCID, 4, 0),()),
  "Sent" : ((33, LCID, 4, 0),()),
  "Session" : ((34, LCID, 4, 0),()),
  "Signed" : ((35, LCID, 4, 0),()),
  "Size" : ((36, LCID, 4, 0),()),
  "Submitted" : ((18, LCID, 4, 0),()),
  "TimeReceived" : ((40, LCID, 4, 0),()),
  "TimeSent" : ((41, LCID, 4, 0),()),
  "Unread" : ((42, LCID, 4, 0),()),
  "folderID" : ((51, LCID, 4, 0),()),
  "importance" : ((27, LCID, 4, 0),()),
  "storeID" : ((52, LCID, 4, 0),()),
  "subject" : ((38, LCID, 4, 0),()),
  "text" : ((39, LCID, 4, 0),()),
  "type" : ((17, LCID, 4, 0),()),
 }

This give you the methods (Send, Delete, Update...) + attributes (Application,
Attachements,...) [and actually some you can get and/or put]
so you in my previous example I used  "msg.subject", you can also get msg.text
to get the body of the message.
What is less obvious is thing such as Recipients, because Recipients is a
collection of objects (ie Recipient), but you can find the description of the
class Recipient in the same .py generated by makepy.

Or again look at CDO (under "Platform SDK, Database and Messaging Services") in
MSDN Library.





More information about the Python-list mailing list