Click here to Skip to main content
15,907,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Odd MessageBox Problem Pin
sir kaber6-Aug-05 13:49
sir kaber6-Aug-05 13:49 
GeneralRe: Odd MessageBox Problem Pin
John R. Shaw7-Aug-05 0:22
John R. Shaw7-Aug-05 0:22 
GeneralRe: Odd MessageBox Problem Pin
sir kaber7-Aug-05 9:00
sir kaber7-Aug-05 9:00 
GeneralDialog problems with VC6.0 built under XP Pin
Haakon S.6-Aug-05 12:36
Haakon S.6-Aug-05 12:36 
GeneralRe: Dialog problems with VC6.0 built under XP Pin
John R. Shaw7-Aug-05 1:26
John R. Shaw7-Aug-05 1:26 
GeneralRe: Dialog problems with VC6.0 built under XP Pin
Haakon S.7-Aug-05 3:36
Haakon S.7-Aug-05 3:36 
GeneralRe: Dialog problems with VC6.0 built under XP Pin
Gary R. Wheeler7-Aug-05 3:32
Gary R. Wheeler7-Aug-05 3:32 
QuestionMAPI: How to read PR_MANAGER_NAME? Pin
Mark Findlay6-Aug-05 11:44
Mark Findlay6-Aug-05 11:44 
Hello Experts!

I am able to retrieve all the profile properties for a user except the PR_MANAGER_NAME property. All of the other fields fetch fine. All the name, address, custom attributes.. you name it, they retrieve fine. The only one that fails is PR_MANAGER_NAME. This fails on all machines tested.

Below is my code (in abbreviated form, that retrieves a single property). You can plug this code into a simple Win32 project (that supports MFC) and it will build and run for you. You will notice about 1/2 way down where I set the property to be read:

//aSenderProps.aulPropTag[0] = 0x3001001E; // PR_DISPLAY_NAME <==== THIS WORKS
aSenderProps.aulPropTag[0] = 0x3A4E001E; // PR_MANAGER_NAME <==== THIS FAILS

Can anyone shed any light on why this is failing? Many thanks in advance!

//======== Code below ====================

// MapiTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "MapiTest.h"
#include <mapix.h>
#include <atlconv.h>
#include <atlbase.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
USES_CONVERSION;

int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}

#define MAPI_INIT_VERSION 0

MAPIINIT_0 mapiInit;

mapiInit.ulVersion = MAPI_INIT_VERSION;
mapiInit.ulFlags = MAPI_MULTITHREAD_NOTIFICATIONS;
CComPtr<imapisession> spMapiSession;

// initialize MAPI
HRESULT hr = ::MAPIInitialize(&mapiInit);

if (!SUCCEEDED(hr))
{
AfxMessageBox("MAPIInitialize error");
}

// logon to the profile
hr = ::MAPILogonEx(0, _T("MS Exchange Settings"), NULL, MAPI_EXTENDED|MAPI_NO_MAIL|MAPI_NEW_SESSION|MAPI_TIMEOUT_SHORT, &spMapiSession);
if (FAILED(hr))
{
AfxMessageBox("Unable to logon");
return 0;
}

CComPtr<imapiprop> spSender;
ULONG uObjectType, uCount, cbSenderEntryIDSize;
LPENTRYID pSenderEntryID=NULL;
LPSPropValue pSenderProps=NULL;

// struct used to hold array of properties to read
struct _SPropTagArray_
{
ULONG cValues;
ULONG aulPropTag[1];
} aSenderProps;

// set the properties to read (in this case, 1 property)
aSenderProps.cValues = 1;
//aSenderProps.aulPropTag[0] = 0x3001001E; // PR_DISPLAY_NAME <= = = = = = = = = = = = == THIS WORKS
aSenderProps.aulPropTag[0] = 0x3A4E001E; // PR_MANAGER_NAME <= = = = = = = = = = = = = THIS FAILS

// Get the Entry Identifier used to read the primary identity
hr = spMapiSession->QueryIdentity(&cbSenderEntryIDSize,&pSenderEntryID);
if (FAILED(hr))
{
AfxMessageBox("Unable to QueryIdentity");
return 0;
}

if (hr == MAPI_W_NO_SERVICE)
{
AfxMessageBox("MAPI_W_NO_SERVICE");
return 0;
}


// OpenEntry
hr = spMapiSession->OpenEntry( cbSenderEntryIDSize,
pSenderEntryID,
NULL,
MAPI_BEST_ACCESS | MAPI_DEFERRED_ERRORS,
&uObjectType,
(LPUNKNOWN FAR *)&spSender);
if (FAILED(hr))
{
AfxMessageBox("Unable to OpenEntry");
return 0;
}

// get the properties
hr = spSender->GetProps( (LPSPropTagArray)&aSenderProps,
0,
&uCount,
&pSenderProps);
if(FAILED(hr))
{
// report, but not fatal
}

CComBSTR bstrTemp;

// display each property found
for (UINT i = 0 ; i < aSenderProps.cValues; i++)
{
if (PROP_TYPE(pSenderProps[i].ulPropTag) != PT_ERROR)
{
// successful read
bstrTemp = pSenderProps[i].Value.lpszA;
AfxMessageBox(CString(bstrTemp));
}
else
{
// unable to read property
bstrTemp = "";
AfxMessageBox("Error: Unable to read property");
}
}

// cleanup

spMapiSession->Logoff(0,0,0);

if (pSenderEntryID)
::MAPIFreeBuffer(pSenderEntryID);

if (pSenderProps)
::MAPIFreeBuffer(pSenderProps);

//MAPIUninitialize();

return nRetCode;
}

// ======== END OF CODE ========================

Mark
AnswerRe: MAPI: How to read PR_MANAGER_NAME? Pin
Jose Lamas Rios6-Aug-05 14:44
Jose Lamas Rios6-Aug-05 14:44 
GeneralRe: MAPI: How to read PR_MANAGER_NAME? Pin
Mark Findlay6-Aug-05 14:47
Mark Findlay6-Aug-05 14:47 
GeneralRe: MAPI: How to read PR_MANAGER_NAME? Pin
Jose Lamas Rios6-Aug-05 14:50
Jose Lamas Rios6-Aug-05 14:50 
GeneralRe: MAPI: How to read PR_MANAGER_NAME? Pin
ctbfalcon10-Jun-09 6:07
ctbfalcon10-Jun-09 6:07 
Generalctreectrl help Pin
picazo6-Aug-05 10:04
picazo6-Aug-05 10:04 
GeneralRe: ctreectrl help Pin
picazo6-Aug-05 10:06
picazo6-Aug-05 10:06 
GeneralRe: ctreectrl help Pin
Jörgen Sigvardsson6-Aug-05 12:50
Jörgen Sigvardsson6-Aug-05 12:50 
GeneralRe: ctreectrl help Pin
picazo6-Aug-05 14:00
picazo6-Aug-05 14:00 
QuestionVC++ 6 Std, VC++ Toolkit 2003 and ATL/WTL/MFC ? Pin
Defenestration6-Aug-05 8:03
Defenestration6-Aug-05 8:03 
General1GDI - drawing the sin( ) function Pin
yanivbd16-Aug-05 8:01
sussyanivbd16-Aug-05 8:01 
GeneralPut Controls into Taskbar Pin
Nautilus Master6-Aug-05 7:30
Nautilus Master6-Aug-05 7:30 
QuestionCLongBinary to CBitmap? Pin
Razi Al-Sayed6-Aug-05 7:06
Razi Al-Sayed6-Aug-05 7:06 
AnswerRe: CLongBinary to CBitmap? Pin
John R. Shaw7-Aug-05 2:02
John R. Shaw7-Aug-05 2:02 
QuestionDetecting other software interacting with my software? Pin
luddet6-Aug-05 4:33
luddet6-Aug-05 4:33 
AnswerRe: Detecting other software interacting with my software? Pin
John R. Shaw7-Aug-05 2:24
John R. Shaw7-Aug-05 2:24 
GeneralHeapFree and virtual memory Pin
S. Senthil Kumar6-Aug-05 3:54
S. Senthil Kumar6-Aug-05 3:54 
GeneralRe: HeapFree and virtual memory Pin
Tim Smith6-Aug-05 4:27
Tim Smith6-Aug-05 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.