I am creating default mail application like thunderbird and outlook but with some of the features only. So now problem is only with the word 2007 and excel 2007 while sending file from fileMenu -> send -> E-mail and application gets crashed after clicking on E-mail, but same thing is working in Powerpoint 2007 and one note 2007.
With office 2007, MapiLogon(...) is getting first call and here is my MAPILogOn(...),
// I have used ofstream for the log purpose.
#include <MAPIX.h>
extern "C" ULONG MAPILogon(ULONG_PTR ulUIParam, LPSTR lpszProfileName, LPSTR lpszPassword, FLAGS flFlags, ULONG ulReserved, LPLHANDLE lplhSession)
{
ofstream outfile;
outfile.open("e:\\temp\\MAPILogon.txt");
HRESULT hrs = NULL;
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSION, MAPI_NO_COINIT };
hrs = MAPIInitialize(NULL);
lplhSession = nullptr;
if (hrs != S_OK)
{
outfile << "\n MAPI uniititalized";
}
else
{
outfile << "\n MAPI initialized";
LPMAPISESSION FAR spSession = NULL;
outfile << "\n lplhsession - " << spSession;
hrs = MAPILogonEx(NULL, "Outlook", NULL, MAPI_EXTENDED | MAPI_NEW_SESSION, &spSession);
if (hrs == NULL)
{
outfile << "\n MAPI problem while log in." << spSession;
}
else if (hrs == S_OK)
{
outfile << "\n MAPI log in successful.";
return SUCCESS_SUCCESS;
}
outfile << "\n Last Error - " << GetLastError();
}
return MAPI_E_FAILURE;
}
Here, I am able to initialize MAPI successfully, but MAPILogOnEx(...) returns null, so are there any other things that are required here?
GetLastError() gives 0. "Outlook" is the default profile.
I have looked all the tutorials of stackoverflow and Microsoft but unable to get solution.