Outlook 2007 on Windows Vista - can't programatically create a MAPI profile

S

Stuart Bray

Hi there,

I can't seem to figure out why IProfAdmin::CreateProfile is returning
MAPI_E_CALL_FAILED on Windows Vista with Outlook 2007. It works fine
on all previous versions of Windows, even works on Windows XP with
Outlook 2007. It doesn't seem to be a UAC issue - running even as
Administrator gives me the error.

Is there a new way to progamatically create MAPI profiles under Vista?
Has anyone else noticed this problem?

Any help would be greatly appreciated. Thanks!
 
S

stu.bray

Are you sure a profile with the same name does not already exist?

Hi Dmitry, thanks for getting back to me so soon. I have verified
that the profile name I'm trying to create is unique. I even delete
any profile by that name before calling CreateProfile. The strange
thing I found was that CreateProfile is actually creating a MAPI
profile with the name I give it, but since it's returning
MAPI_E_CALL_FAILED and not S_OK, our application deletes the profile
we just tried to create in our error cleanup routine. I haven't yet
tried to force it to continue even if I get the MAPI_E_CALL_FAILED; it
might be an interesting data point if it continues to work under that
case.

Here's a little snippet of code:

// Delete the profile if it exists
profAdmin.DeleteProfile(PChar(profileName), 0);

hr := profAdmin.CreateProfile(PChar(profileName),
nil,
0,
0);

I've also tried MAPI_DEFAULT_SERVICES for the flags, with no
success.

Thanks again for any insight you can provide!

-Stu
 
D

Dmitry Streblechenko

Hmmm.. I don't know.
Does it happen 100% of the time or only intermittently? Did you try to
create a profile with a name that you never used before (just in case of
some weird caching)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
S

stu.bray

Hmmm.. I don't know.
Does it happen 100% of the time or only intermittently? Did you try to
create a profile with a name that you never used before (just in case of
some weird caching)?


Hi Dmitri. Some updates: I have tried to create a profile with a name
I've not used before, still the same problem.

Something strange: I've created a sample Delphi application that runs
virtually the same "Create Profile" code, and it works! So, it
appears to be something in our main application that is causing the
MAPI subsystem to respond differently for IProfAdmin::CreateProfile
under Vista. All the calls are running in our main thread where we do
MAPIInitialize. I'm a bit stumped.

Still investigating...
 
S

stu.bray

2/14/2007 1:59:40:641 PM (3940) - component: MAPI 1.0
2/14/2007 1:59:42:860 PM (3940) - error: An unexpected error has
occurred.
2/14/2007 1:59:46:970 PM (3940) - context: 1127
2/14/2007 1:59:48:032 PM (3940) - low level error: 0
2/14/2007 1:59:52:142 PM (3940) - version is 0
 
S

stu.bray

How does your app call CoInitialize and MAPIinitialize?

We call both CoInitialize(nil) and MAPIInitialize(nil) in our app from
the same main thread.

I have another strange update on this problem. I found that in our
version.rc file, we have the line:

PRODUCTVERSION 1,0,0,0

Now, if I change the first number to _any_ other number, (2,0,0,0 for
example), it works! Very strange. This was a bug in our code, so I've
fixed it to actually set the product version and now CreateProfile
doesn't give me MAPI_E_CALL_FAILED. However, I am still stumped as to
how this actually fixes the bug! I need to read up more on .rc files,
maybe I'm missing something here.

Any ideas of why this is happening? Thanks again.
 
D

Dmitry Streblechenko

Hmmm... I have never seen that happen.
Does your Delphi app stop working if you set its version to 1.0.0.0 (Project
| Options | Version Info)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top