Basic MAPI

Grant Edwards grante at visi.com
Thu Dec 28 20:05:25 CET 2000


In article <91vfsb02cn6 at news2.newsguy.com>, Alex Martelli wrote:
>"Henrik Mårtensson" <henrik.martensson at frontconsulting.se> wrote:
>
>> I'm trying to run a basic MAPI initialisation, but I get stuck
>> with the dispatcher.
>    ...
>> >>> s=Dispatch("Mapi.Session")
>
>There is no creatable coclass (that I ever heard of) with progId
>'Mapi.Session'.

That's what I use:

[...]

class MapiFetcher:
    
    def __init__(self, settings = "MS Exchange Settings"):
        self.sessionSettings = settings
        self.session = None
	self.debugLevel=0

    def Logon(self):
        self.session = win32com.client.Dispatch("MAPI.Session")
        self.session.Logon(self.sessionSettings)
	if self.debugLevel > 1:
	    sys.stderr.write("MapiFetcher: MAPI.Session Logon() with settings = '%s'\n" % (self.sessionSettings,))
    
    def CheckInbox(self):
        inbox = self.session.Inbox
        collmsg = inbox.Messages
	if self.debugLevel > 1:
	    sys.stderr.write("MapiFetcher: Found %d messages in Inbox\n" % (collmsg.Count,))
        messages = []
        
        msg = collmsg.GetFirst()

        while msg:
            [...]
            msg = collmsg.GetNext()
    
[...]
    
>> Below I have pasted the code I'm running. Is there something
>> that you have to do to make the MAPI interface available to
>> you? I'm not running this in a MS Exchange office environment.

I don't know what that means.  The machine on which my code
runs has MS-Outlook installed, and there's an Exchange Server
somewhere...

>You have to instantiate a coclass that will let you get at a
>relevant MAPI object model.  The progId you will use will
>depend on what MAPI-supplying product you want to use --
>Exchange Server, Outlook, Eudora, Netscape, whatever.  With
>Outlook, for example, the Session property of the Outlook
>application object (which is a creatable coclass, with a
>progId of 'Outlook.Application') might serve your needs.

-- 
Grant Edwards                   grante             Yow!  I like your SNOOPY
                                  at               POSTER!!
                               visi.com            



More information about the Python-list mailing list