ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Python-win32
Python-win32
RE: [python-win32] Creating a Profile programmatically.
by Mark Hammond other posts by this author
Sep 28 2004 1:17AM messages near this date
[python-win32] Creating a Profile programmatically. | [python-win32] How do I get a PyIMAPIProps ?
>  I've been using exchange e-mail proiles to Logon( )to Exchange MAPI
Sessions.
>  Now I would like to create the Profile programmatically, instead of
clicking
>  through the Mail stuff, and have them be persistent across executions of
the

Below is some code that should work.  Python simply wraps most of these MAPI
functions - so your best best is to find the C++ sample code provided by
MS - especially the 'exchange' and 'exchdapi' ones, such as
HrCreateProfileName().  You should even be able to find the MS C++ source to
those "Hr" functions, so see how it can be done at the raw MAPI level.

Depending on your app, you may or may not need a "mailbox agent".

Mark.

ret = exchange.HrCreateProfileName(profileName)
# Attempt to delete the existing profile.
try:
    exchdapi.HrRemoveProfile(profileName)
except pythoncom.error:
    pass

# Occasionally MAPI takes some time to catch up - eg, if this code
# is running from a service and not explicitly marked dependent on
# Exchange, Exchange itself may still be starting.
# You may need to add this code in a loop that handles failure and
# retries.
try:
    exchdapi.HrCreateMailboxAgentProfile(yourProgramName, ret)
except pythoncom.com_error, (hr, desc, exc, arg):
    if hr == winerror.E_ACCESSDENIED:
        # the profile exists, and is in use - just use it.
        pass
    else:
        # all other errors are real errors.
        raise

return ret

_______________________________________________
Python-win32 mailing list
Python-win32@[...].org
http://mail.python.org/mailman/listinfo/python-win32
Thread:
Aaron Patrick Lehmann
Mark Hammond

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved