473,500 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO, Python and MS Exchange

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"
conn.Open()

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

rs.Open("Select http://schemas.microsoft.com/exchange/foldersize from
scope ('deep traversal of http://ctex01/exchange/warren.ali')",
conn.ConnectionString)

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

Traceback (most recent call last):
File "C:\Python24\ad.py", line 12, in -toplevel-
rs.Open("Select http://schemas.microsoft.com/exchange/foldersize
from scope ('deep traversal of http://ctex01/exchange/warren.ali')",
conn.ConnectionString)
File
"C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129-B803-931327F72D5Cx0x2x8\_Recordset.py",
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: http://www.mayukhbose.com/python/ado/index.php
but cant seem to adapt it to talk to exchange

This is the code that works via vbscript

http://support.microsoft.com/kb/2913

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

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

sSQL = "Select"
sSQL = sSQL & "
""http://schemas.microsoft.com/exchange/foldersize"" "
'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

Thanks!!

--
Keeping it (sur)real since 1981. (now in
print:http://thinkingmachine.blogsome.com)

Jul 18 '05 #1
0 1501

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1702
by: cognite | last post by:
This venue would surely appreciate the cool stuff being done in python on bioinformatics and python's tools for info parsing and extraction (like fulltext indexing, xml tools, parser builders,...
5
2220
by: Max Ischenko | last post by:
Hi, I've started to develop under Microsoft ASP framework, which allows different lang. used in a ActiveX page. I wonder about possible strategies to use Python modules from VBScript <%%>...
5
4696
by: Lindstrom Greg - glinds | last post by:
I'm using python 2.3 and Windows 2000 "Professional" to access a Microsoft Exchange Server to monitor messages and perform various tasks around the office. My little program is attracted quite a...
14
9865
by: sridhar | last post by:
iam having user account on an exchangeserver. with that can i send an email using python? if iam using the following code iam getting error fromAddress = 'sridhar_kasturi@satyam.com'...
852
27935
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
14
2133
by: Paddy3118 | last post by:
This month there was/is a 1000+ long thread called: "merits of Lisp vs Python" In comp.lang.lisp. If you followed even parts of the thread, AND previously used only one of the languages AND...
3
7184
by: Yusniel | last post by:
Hi friends. Someone know how to work with python and exchange server?.
1
1055
by: Jean-Paul Calderone | last post by:
On Mon, 5 May 2008 11:11:19 -0700 (PDT), TkNeo <tarun.kap@gmail.comwrote: FWIW, though not as complete as an OpenSSL wrapper as M2Crypto, pyOpenSSL works with Python 2.3. As far as the details...
3
3905
by: Beliavsky | last post by:
I work for a financial company where we run Windows XP and read email using Microsoft Outlook 2003. I get daily files that come as email attachments from various counterparties. I save them as...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.