469,569 Members | 1,514 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,569 developers. It's quick & easy.

Outlook-MAPI

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

Jul 19 '05 #1
1 8248
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


Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jyothi | last post: by
reply views Thread by Martin Knauer | last post: by
10 posts views Thread by John | last post: by
26 posts views Thread by Tom Becker | last post: by
5 posts views Thread by fniles | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.