Discussion:
MAPIInitialize failed and get an error message
(too old to reply)
zhanglr
2007-04-10 21:32:00 UTC
Permalink
Hi,

I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and set it
as the default mail client.

BTW, my pc setting is:
OS is Vista.
IDE is Microsoft Visual Studio 2005
email client:
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the password or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)

Best Regards,
Michael
Dmitry Streblechenko
2007-04-11 06:18:51 UTC
Permalink
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and set it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the password or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-11 15:32:04 UTC
Permalink
Hi Dmitry,

First of all, thank you for your reply.

I try to load msmapi32.dll but when I call the function MAPIInitialize, I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared with a
different calling convention.

Would you please tell me how to solve this problem?

------------------------------------------------------------------
BTW, the following is the code:

typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);

void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;

if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;

if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}

FreeLibrary(hLib);
}
}

Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and set it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the password or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
Dmitry Streblechenko
2007-04-11 17:32:38 UTC
Permalink
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function MAPIInitialize, I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared with a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the
MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-11 20:04:01 UTC
Permalink
Hi Dmitry,

Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.

But I get another error when I call MAPILogonEx:
-- 0x80040111 ( ClassFactory cannot supply required class )

Would you please tell me how to solve it?

BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But it also
links mapi32.lib.

At the end, thanks again for your help.

----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR, LPTSTR,
FLAGS, LPMAPISESSION FAR *);

void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;

if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;

CComPtr<IMAPISession> pSession = NULL;

if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib, "MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );

hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}

FreeLibrary(hLib);
}
}

Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function MAPIInitialize, I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared with a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
Dmitry Streblechenko
2007-04-11 20:33:26 UTC
Permalink
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But it also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR, LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib, "MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function MAPIInitialize, I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-12 21:40:03 UTC
Permalink
Hi,

First of all, I am sorry I did not reply it until now. The reason is I am
not able to login to hotmail.

Yes. you are right. It is working now. Thank you so much.

One more question:
Now I just dynamically load library for MAPIInitialize, MAPIUninitialize,
MAPILogonEx, MAPIAllocateBuffer and MAPIFreeBuffer.

I still leave HrQueryAllRows and FreeProws to rely on mapi32.lib. (it will
crash if I do the same as MAPIInitialize,MAPIUninitialize...)

Do you think it is OK?

At the end, thank you so much for your help again.

Have a good day.

Yours,
Michael
Post by Dmitry Streblechenko
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But it also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR, LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib, "MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function MAPIInitialize, I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically linking., The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
Stephen Griffin [MSFT]
2007-04-12 21:50:17 UTC
Permalink
You just need to import them right:
typedef SCODE (STDMETHODCALLTYPE HRQUERYALLROWS)(
LPMAPITABLE lpTable,
LPSPropTagArray lpPropTags,
LPSRestriction lpRestriction,
LPSSortOrderSet lpSortOrderSet,
LONG crowsMax,
LPSRowSet FAR *lppRows);
typedef HRQUERYALLROWS *LPHRQUERYALLROWS;

typedef void (STDMETHODCALLTYPE FREEPROWS)(
LPSRowSet lpRows);
typedef FREEPROWS *LPFREEPROWS;

LPHRQUERYALLROWS pfnHrQueryAllRows = NULL;
LPFREEPROWS pfnLPFreeProws = NULL;
Post by zhanglr
Hi,
First of all, I am sorry I did not reply it until now. The reason is I am
not able to login to hotmail.
Yes. you are right. It is working now. Thank you so much.
Now I just dynamically load library for MAPIInitialize, MAPIUninitialize,
MAPILogonEx, MAPIAllocateBuffer and MAPIFreeBuffer.
I still leave HrQueryAllRows and FreeProws to rely on mapi32.lib. (it will
crash if I do the same as MAPIInitialize,MAPIUninitialize...)
Do you think it is OK?
At the end, thank you so much for your help again.
Have a good day.
Yours,
Michael
Post by Dmitry Streblechenko
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But
it
also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR,
LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib,
"MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function
MAPIInitialize,
I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the MAPIInitialize
function? You need to call LoadLibrary instead of statically
linking.,
The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail
client
cannot
fulfill the messaging request. Please run Microsoft Office
Outlook
and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If
you
are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail
program
you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-13 14:20:05 UTC
Permalink
Hi Stephen,

It works. Thank you so much.

BTW, what does @24 and @4 means? Where do you get them?

Thanks again and have a good day.

Yours,
Michael
Post by Stephen Griffin [MSFT]
typedef SCODE (STDMETHODCALLTYPE HRQUERYALLROWS)(
LPMAPITABLE lpTable,
LPSPropTagArray lpPropTags,
LPSRestriction lpRestriction,
LPSSortOrderSet lpSortOrderSet,
LONG crowsMax,
LPSRowSet FAR *lppRows);
typedef HRQUERYALLROWS *LPHRQUERYALLROWS;
typedef void (STDMETHODCALLTYPE FREEPROWS)(
LPSRowSet lpRows);
typedef FREEPROWS *LPFREEPROWS;
LPHRQUERYALLROWS pfnHrQueryAllRows = NULL;
LPFREEPROWS pfnLPFreeProws = NULL;
Post by zhanglr
Hi,
First of all, I am sorry I did not reply it until now. The reason is I am
not able to login to hotmail.
Yes. you are right. It is working now. Thank you so much.
Now I just dynamically load library for MAPIInitialize, MAPIUninitialize,
MAPILogonEx, MAPIAllocateBuffer and MAPIFreeBuffer.
I still leave HrQueryAllRows and FreeProws to rely on mapi32.lib. (it will
crash if I do the same as MAPIInitialize,MAPIUninitialize...)
Do you think it is OK?
At the end, thank you so much for your help again.
Have a good day.
Yours,
Michael
Post by Dmitry Streblechenko
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But
it
also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR,
LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib,
"MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function
MAPIInitialize,
I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the
MAPIInitialize
function? You need to call LoadLibrary instead of statically
linking.,
The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail
client
cannot
fulfill the messaging request. Please run Microsoft Office
Outlook
and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as
default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If
you
are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail
program
you'd
like to use, and then click OK.)
Best Regards,
Michael
Stephen Griffin [MSFT]
2007-04-13 15:29:52 UTC
Permalink
That's just the name of the export. Check out depends.exe:
http://www.dependencywalker.com/
Post by zhanglr
Hi Stephen,
It works. Thank you so much.
Thanks again and have a good day.
Yours,
Michael
Post by Stephen Griffin [MSFT]
typedef SCODE (STDMETHODCALLTYPE HRQUERYALLROWS)(
LPMAPITABLE lpTable,
LPSPropTagArray lpPropTags,
LPSRestriction lpRestriction,
LPSSortOrderSet lpSortOrderSet,
LONG crowsMax,
LPSRowSet FAR *lppRows);
typedef HRQUERYALLROWS *LPHRQUERYALLROWS;
typedef void (STDMETHODCALLTYPE FREEPROWS)(
LPSRowSet lpRows);
typedef FREEPROWS *LPFREEPROWS;
LPHRQUERYALLROWS pfnHrQueryAllRows = NULL;
LPFREEPROWS pfnLPFreeProws = NULL;
Post by zhanglr
Hi,
First of all, I am sorry I did not reply it until now. The reason is I am
not able to login to hotmail.
Yes. you are right. It is working now. Thank you so much.
Now I just dynamically load library for MAPIInitialize,
MAPIUninitialize,
MAPILogonEx, MAPIAllocateBuffer and MAPIFreeBuffer.
I still leave HrQueryAllRows and FreeProws to rely on mapi32.lib. (it will
crash if I do the same as MAPIInitialize,MAPIUninitialize...)
Do you think it is OK?
At the end, thank you so much for your help again.
Have a good day.
Yours,
Michael
Post by Dmitry Streblechenko
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But
it
also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR,
LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib,
"MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function
MAPIInitialize,
I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the
MAPIInitialize
function? You need to call LoadLibrary instead of statically
linking.,
The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail
client
cannot
fulfill the messaging request. Please run Microsoft Office
Outlook
and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as
default
email client.
(1. Click to open Set Program Access and Computer Defaults.?
If
you
are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail
program
you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-13 18:20:05 UTC
Permalink
Hi,

Oh. I see.

Thank you so much and have a good weekend.

Yours,
Michael zhang
Post by Stephen Griffin [MSFT]
http://www.dependencywalker.com/
Post by zhanglr
Hi Stephen,
It works. Thank you so much.
Thanks again and have a good day.
Yours,
Michael
Post by Stephen Griffin [MSFT]
typedef SCODE (STDMETHODCALLTYPE HRQUERYALLROWS)(
LPMAPITABLE lpTable,
LPSPropTagArray lpPropTags,
LPSRestriction lpRestriction,
LPSSortOrderSet lpSortOrderSet,
LONG crowsMax,
LPSRowSet FAR *lppRows);
typedef HRQUERYALLROWS *LPHRQUERYALLROWS;
typedef void (STDMETHODCALLTYPE FREEPROWS)(
LPSRowSet lpRows);
typedef FREEPROWS *LPFREEPROWS;
LPHRQUERYALLROWS pfnHrQueryAllRows = NULL;
LPFREEPROWS pfnLPFreeProws = NULL;
Post by zhanglr
Hi,
First of all, I am sorry I did not reply it until now. The reason is I am
not able to login to hotmail.
Yes. you are right. It is working now. Thank you so much.
Now I just dynamically load library for MAPIInitialize,
MAPIUninitialize,
MAPILogonEx, MAPIAllocateBuffer and MAPIFreeBuffer.
I still leave HrQueryAllRows and FreeProws to rely on mapi32.lib. (it will
crash if I do the same as MAPIInitialize,MAPIUninitialize...)
Do you think it is OK?
At the end, thank you so much for your help again.
Have a good day.
Yours,
Michael
Post by Dmitry Streblechenko
The error is MAPI_E_LOGON_FAILED
Since you are not supplying the profile name, add the MAPI_USE_DEFAULT bit.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
Yes. MAPIInitialize and MAPIUninitialize are working now after I add
STDAPICALLTYPE.
-- 0x80040111 ( ClassFactory cannot supply required class )
Would you please tell me how to solve it?
BTW, do you know where I am able to find a sample of MAPI? I have
downloaded
one from microsoft -- Platform SDK Archive Samples: MAPI Samples. But
it
also
links mapi32.lib.
At the end, thanks again for your help.
----------------------------------------------------
typedef HRESULT (STDAPICALLTYPE *MSMAPIInitialize)(LPVOID);
typedef void (STDAPICALLTYPE *MSMAPIUninitialize)(VOID);
typedef HRESULT (STDAPICALLTYPE *MSMAPILogonEx)(ULONG, LPTSTR,
LPTSTR,
FLAGS, LPMAPISESSION FAR *);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
MSMAPILogonEx fMAPILogonEx = NULL;
CComPtr<IMAPISession> pSession = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize"))
&& (fMAPILogonEx = (MSMAPILogonEx)GetProcAddress (hLib, "MAPILogonEx")) )
{
HRESULT hRs = fMAPIInitialize( NULL );
hRs = fMAPILogonEx( 0, NULL, NULL,
MAPI_EXTENDED | MAPI_NEW_SESSION | MAPI_UNICODE,
&pSession );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards,
Michael
Post by Dmitry Streblechenko
Your function definition is wrong. Specify the STDAPICALLTYPE calling
convention.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi Dmitry,
First of all, thank you for your reply.
I try to load msmapi32.dll but when I call the function
MAPIInitialize,
I
got following error message
-- Run-Time Check Failure #0- The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function
declared with one calling convention with a function pointer declared
with
a
different calling convention.
Would you please tell me how to solve this problem?
------------------------------------------------------------------
typedef HRESULT (*MSMAPIInitialize)(LPVOID);
typedef void (*MSMAPIUninitialize)(VOID);
void CTestDlg::OnBnClickedButton19()
{
HMODULE hLib = NULL;
if(hLib = LoadLibrary (_T("msmapi32.dll")))
{
MSMAPIInitialize fMAPIInitialize = NULL;
MSMAPIUninitialize fMAPIUninitialize = NULL;
if ( (fMAPIInitialize = (MSMAPIInitialize)GetProcAddress (hLib,
"MAPIInitialize"))
&& (fMAPIUninitialize = (MSMAPIUninitialize)GetProcAddress (hLib,
"MAPIUninitialize")) )
{
fMAPIInitialize( NULL );
fMAPIUninitialize();
}
FreeLibrary(hLib);
}
}
Best Regards
Post by Dmitry Streblechenko
You are loading a wrong mapi dll. How exactly do you link the
MAPIInitialize
function? You need to call LoadLibrary instead of statically
linking.,
The
right dll is msmapi32.dll in Program Files.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize(
NULL );
-- Either there is no default mail client or the current mail
client
cannot
fulfill the messaging request. Please run Microsoft Office
Outlook
and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as
default
email client.
(1. Click to open Set Program Access and Computer Defaults.?
If
you
are
prompted for an administrator password or confirmation, type
the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail
program
you'd
like to use, and then click OK.)
Best Regards,
Michael
huzaifa kagazwala
2007-04-11 12:02:13 UTC
Permalink
The error is returned if Outlook is not your default mail client and the
default mail client does not support MAPI. There are two ways of getting
around this problem.

1.. Make Microsoft Outlook your default mail client.
2.. Or make an entry for you application under the path
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Messaging
Subsystem\\MSMapiApps" with the value set to "Microsoft Outlook". This will
divert all MAPI related calls to Outlook even if it is not the default mail
client.
Regards,
Huzaifa Kagazwala
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and set it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the password or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-11 15:12:01 UTC
Permalink
Hi,

First of all, thank you for reply.

But, I cannot ask user to change the config. And I am not right to modify
any record under HKEY_LOCAL_MACHINE in vista.

Any other suggestion?

Best Regards
Post by huzaifa kagazwala
The error is returned if Outlook is not your default mail client and the
default mail client does not support MAPI. There are two ways of getting
around this problem.
1.. Make Microsoft Outlook your default mail client.
2.. Or make an entry for you application under the path
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Messaging
Subsystem\\MSMapiApps" with the value set to "Microsoft Outlook". This will
divert all MAPI related calls to Outlook even if it is not the default mail
client.
Regards,
Huzaifa Kagazwala
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and set it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the password or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
Stephen Griffin [MSFT]
2007-04-12 14:55:57 UTC
Permalink
If you can't change the config, then it's up to you to load Outlook's MAPI
manually. You won't be able to rely on mapi32.lib and the MAPI stub library.

You REALLY need to read this article:
http://blogs.msdn.com/stephen_griffin/archive/2007/01/18/where-did-mapisvc-inf-go.aspx

FGetComponentPath is gonna be your best friend here in locating Outlook's
MAPI.

Steve
Post by zhanglr
Hi,
First of all, thank you for reply.
But, I cannot ask user to change the config. And I am not right to modify
any record under HKEY_LOCAL_MACHINE in vista.
Any other suggestion?
Best Regards
Post by huzaifa kagazwala
The error is returned if Outlook is not your default mail client and the
default mail client does not support MAPI. There are two ways of getting
around this problem.
1.. Make Microsoft Outlook your default mail client.
2.. Or make an entry for you application under the path
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Messaging
Subsystem\\MSMapiApps" with the value set to "Microsoft Outlook". This will
divert all MAPI related calls to Outlook even if it is not the default mail
client.
Regards,
Huzaifa Kagazwala
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
zhanglr
2007-04-12 21:26:03 UTC
Permalink
Hi,

Yes. It is really helpful. Thank you so much.

Yours,
Michael
Post by Stephen Griffin [MSFT]
If you can't change the config, then it's up to you to load Outlook's MAPI
manually. You won't be able to rely on mapi32.lib and the MAPI stub library.
http://blogs.msdn.com/stephen_griffin/archive/2007/01/18/where-did-mapisvc-inf-go.aspx
FGetComponentPath is gonna be your best friend here in locating Outlook's
MAPI.
Steve
Post by zhanglr
Hi,
First of all, thank you for reply.
But, I cannot ask user to change the config. And I am not right to modify
any record under HKEY_LOCAL_MACHINE in vista.
Any other suggestion?
Best Regards
Post by huzaifa kagazwala
The error is returned if Outlook is not your default mail client and the
default mail client does not support MAPI. There are two ways of getting
around this problem.
1.. Make Microsoft Outlook your default mail client.
2.. Or make an entry for you application under the path
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Messaging
Subsystem\\MSMapiApps" with the value set to "Microsoft Outlook". This will
divert all MAPI related calls to Outlook even if it is not the default mail
client.
Regards,
Huzaifa Kagazwala
Post by zhanglr
Hi,
I get following error message when I call MAPIInitialize( NULL );
-- Either there is no default mail client or the current mail client cannot
fulfill the messaging request. Please run Microsoft Office Outlook and
set
it
as the default mail client.
OS is Vista.
IDE is Microsoft Visual Studio 2005
1) outlook 2003 (no default)
2) Windows mail (default email client) -- I manually set it as default
email client.
(1. Click to open Set Program Access and Computer Defaults.? If you are
prompted for an administrator password or confirmation, type the
password
or
provide confirmation.
2. Under Choose a configuration, click Custom.
3. Under Choose a default e-mail program, click the e-mail program you'd
like to use, and then click OK.)
Best Regards,
Michael
Loading...