473,781 Members | 2,413 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.Connection String = "URL=http://ctmx01/exchange/warren.ali"
conn.Open()

rs = Dispatch('ADODB .RecordSet')
rs.ActiveConnec tion = conn

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

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.Connection String)
File
"C:\Python24\li b\site-packages\win32c om\gen_py\2A751 96C-D9EB-4129-B803-931327F72D5Cx0x 2x8\_Recordset. py",
line 93, in Open
return self._oleobj_.I nvokeTypes(1022 , LCID, 1, (24, 0), ((12, 17),
(12, 17), (3, 49), (3, 49), (3, 49)),Source, ActiveConnectio n,
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("A DODB.Record")
Set Rs = CreateObject("A DODB.Recordset" )

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

sSQL = "Select"
sSQL = sSQL & "
""http://schemas.microso ft.com/exchange/foldersize"" "
'sSQL = sSQL & ", ""DAV:displayna me"" "
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.ActiveConne ction

Thanks!!

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

Jul 18 '05 #1
0 1523

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

Similar topics

0
1720
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, graphic display, realtime simulation and communities tools like pygame and ...) It's in San Diego February 9-12, 2004. "Session presentations are 45 or 90 minutes long, and tutorials are either a half-day (3 hours) or a full day (6 hours)."
5
2244
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 <%%> includes. Right now I'm thinking about this approaches: - create a COM server in Python to be able to call it from VB. Drawbacks: cumbersome and (probably) slow. - pure data exchange. Python code sets some data in global env. that is
5
4732
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 bit of attention and I have been asked to add some features, but I don't know how to do a couple of things. Can anyone either help me out with the details, or point me to where I can get the information? Here's my task list: 1. Create a...
14
9903
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' toAddress = 'sridhar_kasturi@satyam.com' msg = "Subject: Hello\n\nThis is the body of the message." import smtplib
852
28731
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 my general education. Mark
14
2188
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 (and this is the crucial bit), were persuaded to have a more positive view of the other language; (deep breath, this is a long, as well as grammatically incorrect sentence), THEN WHY NOT POST ON WHAT ARGUMENTS PERSUADED YOU.
3
7213
by: Yusniel | last post by:
Hi friends. Someone know how to work with python and exchange server?.
1
1066
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 of the authentication that you are attempting go, it sounds like you want to use ephemeral DH key exchange. This is something which is on my list to figure out. ;) Jean-Paul
3
3923
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 h:\firm_name \yyyymmdd.csv . Would Python be a good tool to automate the process of saving reports, or would it be more convenient to use a Microsoft proprietary language such as VB or C#? Of course one factor is one's relative competence with the...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.