ADO, Python and MS Exchange

Discussion in 'Python' started by warren ali, Dec 23, 2004.

  1. warren ali

    warren ali Guest

    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)
     
    warren ali, Dec 23, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nita
    Replies:
    1
    Views:
    905
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    493
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    0
    Views:
    1,345
  4. www.westerncartooncards.ca

    Exchange Links < Western Cartoon Cards > Exchange Links

    www.westerncartooncards.ca, Jul 12, 2004, in forum: HTML
    Replies:
    2
    Views:
    1,292
    Toby Inkster
    Jul 12, 2004
  5. Alessandro Barracco

    matrix: exchange rows + exchange columns

    Alessandro Barracco, Jan 25, 2011, in forum: Ruby
    Replies:
    0
    Views:
    178
    Alessandro Barracco
    Jan 25, 2011
Loading...

Share This Page