[python-win32] Operational errorr :

Tim Golden mail at timgolden.me.uk
Fri Dec 21 10:41:19 CET 2007


Antony Joseph wrote:
> I am getting Operational Error : when i try get my contacts .
> 
> My code :
> import win32com.client
> oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application")
> onMAPI = oOutlook.GetNamespace("MAPI")
> ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder
> redemption = oOutlook.CreateObject('Redemption.SafeContactItem')

Well your error's coming from this line, but for the life
of me I can't work out what you're trying to do with it,
since it's not used anywhere else. The MSDN help for Outlook
_Application.CreateObject [1] suggests that it's a placeholder for
other methods of creating objects. Maybe you're trying to use
.CreateItem [2] which seems to be used for creating new contact
items.

> for i in range(len(ofContacts.Items)):
>     redemption.Item = ofContacts.Items.Item(i+1)
>     print redemption.Subject

Ah, I think I see. You're trying to create a contact which
then appears in the list this displays. I think you'll need
to save it first with some details as per the Technet link
below {[2]).

TJG

[1] 
http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.createobject.aspx
[2] 
http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0426.mspx



More information about the python-win32 mailing list