<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6396.0">
<TITLE>How to create new MAPI Profile in Python vs C++??</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hi All,</FONT>
<BR> <FONT SIZE=2 FACE="Arial">Anyone know how to create new MAPI Profile in Python base on Microsoft C++ code example(<A HREF="http://support.microsoft.com/default.aspx?scid=kb;EN-US;306962">http://support.microsoft.com/default.aspx?scid=kb;EN-US;306962</A>)??</FONT></P>
<P><FONT SIZE=2 FACE="Arial">this is my source:</FONT>
<BR><FONT SIZE=2 FACE="Arial">===========================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">from win32com.mapi import mapitags,emsabtags</FONT>
<BR><FONT SIZE=2 FACE="Arial">from win32com.mapi import mapi</FONT>
<BR><FONT SIZE=2 FACE="Arial">from win32com.mapi import mapiutil</FONT>
<BR><FONT SIZE=2 FACE="Arial">import pprint,pythoncom</FONT>
<BR><FONT SIZE=2 FACE="Arial">prf='cgf'</FONT>
<BR><FONT SIZE=2 FACE="Arial">mapi.MAPIInitialize(None)</FONT>
<BR><FONT SIZE=2 FACE="Arial">ma=mapi.MAPIAdminProfiles(0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">ma.DeleteProfile(prf,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">mt=ma.GetProfileTable(0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">#print '='*50</FONT>
<BR><FONT SIZE=2 FACE="Arial">#pprint.pprint(mt.QueryRows(mt.GetRowCount(0),0))</FONT>
<BR><FONT SIZE=2 FACE="Arial">pf=ma.CreateProfile(prf,None,0,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">pa=ma.AdminServices(prf,None,0,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">pa.CreateMsgService('MSEMS',None,0,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">pst=pa.GetMsgServiceTable(0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">tbp=pst.QueryRows(mt.GetRowCount(0),0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">print '='*50</FONT>
<BR><FONT SIZE=2 FACE="Arial">pprint.pprint(tbp)</FONT>
<BR><FONT SIZE=2 FACE="Arial">print '='*50</FONT>
<BR><FONT SIZE=2 FACE="Arial">tbr=mapi.HrQueryAllRows(pst,None,None,None,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">pprint.pprint(tbr[0][0][1])</FONT>
<BR><FONT SIZE=2 FACE="Arial">print '='*50</FONT>
<BR><FONT SIZE=2 FACE="Arial">pa.ConfigureMsgService(tbr[0][0][1],0,0,((1711800351,"MyServer"),(1711734815,"csc"))) # it fail in this line</FONT>
<BR><FONT SIZE=2 FACE="Arial">print '='*50</FONT>
<BR><FONT SIZE=2 FACE="Arial">#ma.DeleteProfile(prf,0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">mapi.MAPIUninitialize()</FONT>
<BR><FONT SIZE=2 FACE="Arial">===========================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">result:</FONT>
<BR><FONT SIZE=2 FACE="Arial">===========================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">C:\csc\PY\PyKIV>mpii.py</FONT>
<BR><FONT SIZE=2 FACE="Arial">C:\Python23\lib\site-packages\win32comext\mapi\mapitags.py:59: FutureWarning: x<</FONT>
<BR><FONT SIZE=2 FACE="Arial"><y losing bits or changing sign will return a long in Python 2.4 and up</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return (ulPropID<<16)|(ulPropType)</FONT>
<BR><FONT SIZE=2 FACE="Arial">==================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">(((1024196866, '\xda\xc2\xbf\xe3@\xd0\x83E\xac\x9ds\x8b\xd3G_\xa4'),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (805371934, 'Microsoft Exchange Server'),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (1024000030, 'MSEMS'),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (805896195, 3),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (1024065566, 'emsui.dll'),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (1024131102, 'EMSCfg'),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (1024397342, ('emsui.dll', 'emsabp.dll', 'emsmdb.dll')),</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (267780354, '\xda\xc2\xbf\xe3@\xd0\x83E\xac\x9ds\x8b\xd3G_\xa4')),)</FONT>
<BR><FONT SIZE=2 FACE="Arial">==================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">'\xda\xc2\xbf\xe3@\xd0\x83E\xac\x9ds\x8b\xd3G_\xa4'</FONT>
<BR><FONT SIZE=2 FACE="Arial">==================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">Traceback (most recent call last):</FONT>
<BR><FONT SIZE=2 FACE="Arial"> File "C:\csc\PY\PyKIV\mpii.py", line 23, in ?</FONT>
<BR><FONT SIZE=2 FACE="Arial"> pa.ConfigureMsgService(tbr[0][0][1],0,0,((1711800351,"cbj-s-342"),(171173481</FONT>
<BR><FONT SIZE=2 FACE="Arial">5,"klcsc2")))</FONT>
<BR><FONT SIZE=2 FACE="Arial">pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)</FONT>
<BR><FONT SIZE=2 FACE="Arial">===========================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">Found:</FONT>
<BR> <FONT SIZE=2 FACE="Arial">in Python<B></B></FONT><B> <FONT SIZE=2 FACE="Times New Roman">ConfigureMsgService(<I>iid, ulUIParam, ulFlags, [SPropValue, ...]</I></FONT></B><I></I><FONT SIZE=2 FACE="Times New Roman">)</FONT>
<BR> <FONT SIZE=2 FACE="Arial">in C++</FONT><B></B><B> <FONT SIZE=2 FACE="Times New Roman">HRESULT ConfigureMsgService( LPMAPIUID</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> lpUID</FONT></I><I><B></B></I><B><FONT SIZE=2 FACE="Times New Roman">,</FONT></B><FONT SIZE=2 FACE="Times New Roman"></FONT><B> <FONT SIZE=2 FACE="Times New Roman">ULONG</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> ulUIParam</FONT></I><I><B></B></I><B><FONT SIZE=2 FACE="Times New Roman">,</FONT></B><FONT SIZE=2 FACE="Times New Roman"></FONT><B> <FONT SIZE=2 FACE="Times New Roman">ULONG</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> ulFlags</FONT></I><I><B></B></I><B><FONT SIZE=2 FACE="Times New Roman">,</FONT></B><FONT SIZE=2 FACE="Times New Roman"></FONT><B> <FONT SIZE=2 FACE="Times New Roman">ULONG</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> cValues</FONT></I><I><B></B></I><B><FONT SIZE=2 FACE="Times New Roman">,</FONT></B><FONT SIZE=2 FACE="Times New Roman"></FONT><B> <FONT SIZE=2 FACE="Times New Roman">LPSPropValue</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> lpProps</FONT></I><I><B></B></I><B> <FONT SIZE=2 FACE="Times New Roman">);</FONT></B><FONT SIZE=2 FACE="Times New Roman"> </FONT></P>
<P><FONT SIZE=2 FACE="Arial">Where:</FONT>
<BR> <B></B><B> <FONT SIZE=2 FACE="Times New Roman">LPMAPIUID</FONT></B><I><FONT SIZE=2 FACE="Times New Roman"> lpUID <></FONT></I><I><B> <FONT SIZE=2 FACE="Times New Roman">iid</FONT></B></I>
<BR><FONT SIZE=2 FACE="Arial">in python need IID (GUID) but in C++ need 16 bytes of MAPIUID...</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Anyone know the trick & tips on this???</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">Regards,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Cheeng Shu Chin</FONT>
<BR><FONT SIZE=2 FACE="Arial">SA-Messaging</FONT>
<BR><FONT SIZE=2 FACE="Arial">Shell Information Technology International</FONT>
<BR><FONT SIZE=2 FACE="Arial">2340 Century Square, Jalan Usahawan, 63000 Cyberjaya, Selangor D.E., Malaysia</FONT>
</P>
</BODY>
</HTML>