Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

   

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath
 
 

How to create MS Exchange Profiles in MS Outlook with MAPI

How to create MS Exchange Profiles in MS Outlook with MAPI. Part II

 

 

In the last article you learned how to find a profile and to figure out if it exists or not. Now I’ll tell you how to create and delete profiles.

First, if not already done, you should initialize MAPI and get a IProfAdmin interface.

 

char *pszProfileName; //Name of profile we want to create (update)

// Initialize MAPI.

hr = MAPIInitialize(NULL);

if (!FAILED(hr))

{

                //get IProfAdmin interface

                hr = MAPIAdminProfiles(0, &pProfAdmin);

                if (!FAILED(hr))

{

                                // Create a new empty profile.

                               hr = pProfAdmin->CreateProfile(pszProfileName, NULL, NULL, 0);

                               if (!FAILED(hr))

                                               cout<<”Profile ”<<pszProfileName<<” created successfully”<<endl

                               else

                                               cout<<”Profile ”<<pszProfileName<<” was not created”<<endl

                                }

                }

            As usual don’t forget to release interfaces and uninitialize MAPI.

//Cleanup
                    if (pProfAdmin)             pProfAdmin->Release();
                    MAPIUninitialize();

 

That’s easy.

Just call hr = pProfAdmin->DeleteProfile(pszProfileName, 0) instead of CreateProfile() to delete an existing profile.

 

In conclusion I should explain the fourth parameter in CreateProfile() function. If it’s zero then an empty profile will be created. But if you put MAPI_DEFAULT_SERVICES there, your new created profile will contain default services that were described in the file MAPISVC.INF file under [Default Services] section. Look at this file, we’ll examine it in the next article where we’ll see how to create standard and user defined services within a profile.

 

RETURN to my Article Index


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Stephen Bryant or Pro Exchange. OutlookExchange.Com, Stephen Bryant and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Copyright Stephen Bryant 2008