Outlook-MAPI

Discussion in 'Python' started by V.C.Sekhar, May 9, 2005.

  1. V.C.Sekhar

    V.C.Sekhar Guest

    Hi there,

    Can any one please help in getting me Python-Outlook
    programming issue clarified.



    I just wanted to do the following using Python:

    1)Open a New Oulook Mail Window

    2) Fill the field: to-email address and Write some body to it.(I
    DON't want to send it automatically)



    That's all. But, I am getting an error when I try to initiate the
    MAPI-Session using

    object = win32com.client.Dispatch("Outlook.Application")

    ns = object.GetNamespace("MAPI")

    mapi = win32com.client.dynamic.Dispatch("MAPI.session")



    Error I see is :

    File "C:\Program Files\GNU\WinCvs 2.0\Macros\TemplateCvsMacro.py",
    line 140, in SendMAPIMail

    mapi = win32com.client.Dispatch("MAPI.session")

    File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
    line 95, in Dispatch

    dispatch, userName = dynamic._GetGoodDispatchAndUserName
    (dispatch,userName,clsctx)

    File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py",
    line 91, in _GetGoodDispatchAndUserName

    return (_GetGoodDispatch(IDispatch, clsctx), userName)

    File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py",
    line 79, in _GetGoodDispatch

    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
    pythoncom.IID_IDispatch)

    pywintypes.com_error: (-2147221005, 'Invalid class string', None,
    None)



    Can any one please help me in this regard.



    Thanks,

    Sekhar
    V.C.Sekhar, May 9, 2005
    #1
    1. Advertising

  2. V.C.Sekhar

    Guest

    This code should help.

    code
    import win32com.client
    olMailItem = 0x0
    obj = win32com.client.Dispatch("Outlook.Application")
    newMail = obj.CreateItem(olMailItem)
    newMail.Subject = "This works"
    newMail.Body = "It worked aging\n"
    newMail.display()


    V.C.Sekhar wrote:
    > Hi there,
    >
    > Can any one please help in getting me Python-Outlook
    > programming issue clarified.
    >
    >
    >
    > I just wanted to do the following using Python:
    >
    > 1)Open a New Oulook Mail Window
    >
    > 2) Fill the field: to-email address and Write some body to it.(I
    > DON't want to send it automatically)
    >
    >
    >
    > That's all. But, I am getting an error when I try to initiate the
    > MAPI-Session using
    >
    > object = win32com.client.Dispatch("Outlook.Application")
    >
    > ns = object.GetNamespace("MAPI")
    >
    > mapi = win32com.client.dynamic.Dispatch("MAPI.session")
    >
    >
    >
    > Error I see is :
    >
    > File "C:\Program Files\GNU\WinCvs 2.0\Macros\TemplateCvsMacro.py",
    > line 140, in SendMAPIMail
    >
    > mapi = win32com.client.Dispatch("MAPI.session")
    >
    > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
    > line 95, in Dispatch
    >
    > dispatch, userName = dynamic._GetGoodDispatchAndUserName
    > (dispatch,userName,clsctx)
    >
    > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py",
    > line 91, in _GetGoodDispatchAndUserName
    >
    > return (_GetGoodDispatch(IDispatch, clsctx), userName)
    >
    > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py",
    > line 79, in _GetGoodDispatch
    >
    > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
    > pythoncom.IID_IDispatch)
    >
    > pywintypes.com_error: (-2147221005, 'Invalid class string', None,
    > None)
    >
    >
    >
    > Can any one please help me in this regard.
    >
    >
    >
    > Thanks,
    >
    > Sekhar
    , May 9, 2005
    #2
    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. Elad
    Replies:
    0
    Views:
    747
  2. Mark Hahn
    Replies:
    1
    Views:
    946
    Syver Enstad
    Sep 12, 2003
  3. Chris

    Fun with Outlook and MAPI

    Chris, Dec 10, 2004, in forum: Python
    Replies:
    14
    Views:
    2,300
    Steve Holden
    Dec 13, 2004
  4. Replies:
    1
    Views:
    1,087
    Lenard Lindstrom
    Apr 1, 2007
  5. Jeff Miller

    Win32Ole, MAPI, and Outlook

    Jeff Miller, Mar 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    202
    Brian Scott
    Mar 25, 2008
Loading...

Share This Page