[python-win32] Extended MAPI : ConfigureMsgService Problem
administrator at simonwhitaker.net
administrator at simonwhitaker.net
Sun Jan 16 20:28:25 CET 2005
Hi all,
This is a pseudo follow-up post to a previous question regarding creating and
configuring MAPI profiles dynamically with Python.
There was no posted solution to the question (as far as I can see) so I thought
I'd opst again to see if anyone had any new ideas.
The code is pretty clearly defined in C on MSDN, but when translated to Python,
it fails when configuring services within the created profile.
Included below is the code snippet
---
from win32com.mapi import mapi, mapiutil, mapitags
profileName = "Test"
# Initialise
mapi.MAPIInitialize(None)
profileAdmin = mapi.MAPIAdminProfiles(0)
# Get the current profiles
profileTable = profileAdmin.GetProfileTable(0)
profileRows = mapi.HrQueryAllRows(profileTable, [mapitags.PR_DISPLAY_NAME_A],
None, None, 0)
# Delete the profile if it already exists
for profile in profileRows:
if profile[0][1] == profileName:
profileAdmin.DeleteProfile(profileName, 0)
break
# Create the profile
profileAdmin.CreateProfile(profileName, None, 0, 0)
# Administer the profile services
serviceAdmin = profileAdmin.AdminServices(profileName, None, 0, 0)
serviceAdmin.CreateMsgService('MSEMS', None, 0, 0)
serviceAdmin.CreateMsgService('MSPST MS', None, 0, 0)
# Get the service table - looking for service IDs
msgServiceTable = serviceAdmin.GetMsgServiceTable(0)
msgServiceRows = mapi.HrQueryAllRows(msgServiceTable, None, None, None, 0)
# Get the service ID of the first service
serviceUID = msgServiceRows[1][0][1]
# Configure the MSEMS
propsTuple = ((mapitags.PR_PROFILE_UNRESOLVED_NAME,
"NAME"),(mapitags.PR_PROFILE_UNRESOLVED_SERVER, "SERVER"))
serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) <- !!! FAILS HERE !!!
# Uninitialise
mapi.MAPIUninitialize()
---
The error returned when debugging in PythonWin IDE is
---
Traceback (most recent call last):
File "createprofile.py", line 41, in ?
serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple)
com_error: (-2147221005, 'Invalid class string', None, None)
---
One possible issue is with the serviceUID, which when viewed in the IDE is
[}YÆ8PÍEÅ4ÂY] which looks pretty interesting.
Unfortunately, I have no way of telling if this is the problem, or if there is
another issue.
All assistance/ideas greatly appreciated.
Cheers,
Simon
More information about the Python-win32
mailing list