Trouble with createMessage in 64 bit environment

Sep 1, 2011 at 5:26 PM

Hi Stephen,
I’m having trouble with the following line of code:
hr = lpFolder->CreateMessage(NULL,        // Interface ID, must be NULL for client apps
           MAPI_DEFERRED_ERRORS,
           &lpNewMessage);
It’s returning an access denied. I had implemented the lastError() function,which is returning, “Error 6, the handle is invalid.”


We are currently using Mail Server 2010 and Outlook 2010. The Mail server is running on Win Server 2008 R2 Std 64 bit. The Outlook and my application code are running on Windows 7 Enterprise. This code had worked in the past using almost the same MAPI code with Windows 2007 Server and Outlook 2007. The difference in the code is that now I’m using Explicit Linking, for some functions as required. Outlook and the working application code were running on 32 bit Windows Version 5.1(Build 2600.xpsp_sp3_gdr.101209-1647 Service Pack 3. The other 64 bit mail server is running on Win Server 2003 R2 Std 64bit.


Thank you !!! Your help is greatly appreciated!
Ken Rubin

Overview of Code to get folder, where message is created- I can certainly supply more details if needed of actual code.


I followed the MFCMAPI app to write code to return a folder, several subfolders down in my mailbox. You had reviewed this overview, in the past. What was interesting was that all of the functions are currently giving me good returns and logically going through the directory hierarchy to return a folder.

To Get OpenMsgStore for "Public Folders"
MapilogonEx,QueryRows- get Entry ID, OpenMsgStore (get LPMDB lpMDB) for "Public Folders" folder using Entry ID as input .
To Get to IPM_SUBTREE
Call OpenEntry using lpMDB, GetHierarchyTable, set Columns for Hierarchy, QueryRows on Hierarchy table, get Entry id
for this level.
To Get to a child directory
Call OpenEntry using lpMDB and Entry Id of parent folder, GetHierarchyTable, set Columns for Hierarchy,
QueryRows on Hierarchy table
To return folder
OpenEntry using m_lpContainer and current Entry Id. Check if container is of folder type
and lpFolder = (LPMAPIFOLDER)m_lpContainer;


Explicit Linking Overview
I used Explicit Linking for functions such as MAPIInitialize, Uninitialize, MapiLogonex, PpropFindprop.
1. getRegistryMSIComponentID
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Clients\\Mail\\Microsoft Outlook",NULL, KEY_READ, &hkey);
returnStatus = RegQueryValueExA(hkey,"MSIComponentID",NULL,lpType,NULL,&cb);
returnStatus = RegQueryValueExA(hkey,"MSIComponentID",NULL,lpType,(unsigned char*)lppData,&cb); lppData is return data

2. LoadGetComponentPath
LoadProc(_T("mapi32.dll"), &hModMAPI, "FGetComponentPath", (FARPROC*) &pfnFGetComponentPath); // STRING_OK

3. pfnFGetComponentPath(    lpstr_ptr,
  NULL,
  szAsciiPath,
  _countof(szAsciiPath),
  TRUE);
This returns ascii path of c:\Prog files\Common Files\SYSTEM\MSMAPI\1033\MSMAPI32.DLL
4. HMODULE hMod = NULL;
 hMod = LoadLibrary(ascii path above);
5. Initialize functions for ie. pfnMAPIInitialize = (LPMAPIINITIALIZE) GetProcAddress(hMod, “MAPIINITIALIZE”);

 

 

 

 

 


 

Coordinator
Sep 1, 2011 at 5:35 PM

Typically, if you're getting access denied, then you didn't open the folder with the MAPI_MODIFY flag. So that's the first thing I'd check. Then I'd check the same for OpenMsgStore.

If you had this code working in the past, I'd diff the old code with the current code and focus on exactly what you changed between then and now.

Sep 3, 2011 at 3:10 AM
Hi Stephen,

When I set modify flags in both OpenFolder and OpenMsgStore, I can write the message. Have a good holiday!

Thank you!!

Ken


From: [email removed]
To: [email removed]
Date: Thu, 1 Sep 2011 10:35:31 -0700
Subject: Re: Trouble with createMessage in 64 bit environment [MFCMAPI:271178]

From: sgriffin
Typically, if you're getting access denied, then you didn't open the folder with the MAPI_MODIFY flag. So that's the first thing I'd check. Then I'd check the same for OpenMsgStore.
If you had this code working in the past, I'd diff the old code with the current code and focus on exactly what you changed between then and now.
Read the full discussion online.
To add a post to this discussion, reply to this email (MFCMAPI@discussions.codeplex.com)
To start a new discussion for this project, email MFCMAPI@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com