Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ADO, Python and MS Exchange

Thread Tools

ADO, Python and MS Exchange

warren ali
Posts: n/a
Hi all!

I'm new to python and I seem to have a hit a of a brick wall. I hope
you guys can help.

I'm trying to rewrite some of my vbscripts in python. This particular
script connects to a mailbox in MS Exchange via ADO and calculates the
mailbox size. I seem to have run into a couple of issues getting python
to talk to MS Exchange via ADO though. This is the code i'm using:

from win32com.client import Dispatch

conn = Dispatch('ADODB.Connection')
conn.ConnectionString = "URL=http://ctmx01/exchange/warren.ali"

rs = Dispatch('ADODB.RecordSet')
rs.ActiveConnection = conn

rs.Open("Select from
scope ('deep traversal of http://ctex01/exchange/warren.ali')",

But running the code, all i get is this error message:

Traceback (most recent call last):
File "C:\Python24\", line 12, in -toplevel-
from scope ('deep traversal of http://ctex01/exchange/warren.ali')",
line 93, in Open
return self._oleobj_.InvokeTypes(1022, LCID, 1, (24, 0), ((12, 17),
(12, 17), (3, 49), (3, 49), (3, 49)),Source, ActiveConnection,
CursorType, LockType, Options)
com_error: (-2147352567, 'Exception occurred.', (0, None, '', None, 0,
-2147217900), None)

Does anyone have any suggestions? I've kinda put the code together
based on this tutorial:
but cant seem to adapt it to talk to exchange

This is the code that works via vbscript

Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")

strURL = "http://exchangeserver/exchange/warren.ali"
Rec.Open strURL

sSQL = "Select"
sSQL = sSQL & "
"""" "
'sSQL = sSQL & ", ""DAV:displayname"" "
sSQL = sSQL & " from scope ('deep traversal of " & Chr(34)
sSQL = sSQL & strURL & Chr(34) & "')"
'sSQL = sSQL & "Where ""DAV:isfolder""=true"

' Open the recordset.
Rs.Open sSQL, Rec.ActiveConnection


Keeping it (sur)real since 1981. (now in

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MCSE 2003 w/Exchange or MCITP 2008 w/Exchange Juan MCITP 3 06-19-2009 07:29 PM
Cannot send mail from Exchange 2007 mailbox to Exchange 2003 mailb =?Utf-8?B?am9zdWU=?= MCSE 3 08-15-2007 12:02 PM
Exchange Links < Western Cartoon Cards > Exchange Links HTML 2 07-12-2004 07:59 PM
Exchange 5.5 with Exchange 2000 Cluster problem Jose Luis Microsoft Certification 0 02-13-2004 10:23 AM
help: My exchange lost M: and exchange can not start winman MCSE 9 07-30-2003 04:34 PM