[Zope] Zope, COM and Outlook

Igor Leturia IGOR@emun.com
Mon, 2 Jun 2003 17:13:18 +0200


I tried your suggestion, but this time it says "Error Type: com_error,
Error Value: (-2146959355, 'Error en la ejecuci\xf3n de servidor', None,
None)" (in English it would be something like "Error executing server").
The traceback is the same as before.

		Igor

>
>Try this:
>    # Create instance of Outlook
>    pythoncom.CoInitialize()    ### Added
>    o =3D win32com.client.Dispatch("Outlook.Application")
>
>
>----- Original Message -----=20
>From: "Igor Leturia" <IGOR@emun.com>
>To: <zope@zope.org>
>Sent: Wednesday, May 28, 2003 5:49 PM
>Subject: [Zope] Zope, COM and Outlook
>
>
>  Hi all!
>
>  I need to obtain someone's e-mail address from Outlook's default
>address book. I found a piece of python code in the internet which I
>modified, and it now looks like this:
>
>import codecs, win32com.client
>
>def obtainaddress(name):
>    # Create instance of Outlook
>    o =3D win32com.client.Dispatch("Outlook.Application")
>    mapi =3D o.GetNamespace("MAPI")
>    folder =3D
>mapi.GetDefaultFolder(win32com.client.constants.olFolderContacts)
>    print folder.Item("Igor Leturia").Address
>    o =3D None
>
>obtainaddress('Igor')
>
>  The code needs win32com, so I installed ActivePython and copied the
>win32com folder to Zope's lib. I tested the code in Zope's=20
>python and it
>works.
>
>  But as I need to access it from Zope, I included the function in one
>of the Zope source modules (User.py to be precise). And when I call it
>from DTML, it gives me an error:
>
>Error Type: com_error
>Error Value: (-2147221008, 'CoInitialize not called.', None, None)
>
>  I've put some traces and I know the error is in the first line, o =3D
>win32com.client.Dispatch("Outlook.Application").=20
>
>  Any ideas? Thanks in advance,
>
>Igor Leturia
>
>P.S.: Zope's traceback says:
>
>Traceback (innermost last):
>  File C:\Zope\lib\python\ZPublisher\Publish.py, line 150, in
>publish_module
>  File C:\Zope\lib\python\ZPublisher\Publish.py, line 114, in publish
>  File C:\Zope\lib\python\Zope\__init__.py, line 159, in
>zpublisher_exception_hook
>    (Object: Zope)
>  File C:\Zope\lib\python\ZPublisher\Publish.py, line 98, in publish
>  File C:\Zope\lib\python\ZPublisher\mapply.py, line 88, in mapply
>    (Object: AAAAA)
>  File C:\Zope\lib\python\ZPublisher\Publish.py, line 39, in=20
>call_object
>    (Object: AAAAA)
>  File C:\Zope\lib\python\OFS\DTMLMethod.py, line 130, in __call__
>    (Object: AAAAA)
>  File C:\Zope\lib\python\DocumentTemplate\DT_String.py, line 473, in
>__call__
>    (Object: AAAAA)
>  File C:\Zope\lib\python\DocumentTemplate\DT_Util.py, line=20
>159, in eval
>    (Object: acl_users.getUser('IGOR').getMail())
>    (Info: acl_users)
>  File &lt;string&gt;, line 2, in f
>  File C:\Zope\lib\python\AccessControl\User.py, line 299, in getMail
>  File C:\Archivos de
>programa\Python21\Lib\site-packages\win32com\client\__init__.py, line
>92, in Dispatch
>  File C:\Archivos de
>programa\Python21\Lib\site-packages\win32com\client\dynamic.py,
> line 81,
>in _GetGoodDispatchAndUserName
>  File C:\Archivos de
>programa\Python21\Lib\site-packages\win32com\client\dynamic.py,
> line 72,
>in _GetGoodDispatch
>com_error: (see above)
>
>
>