Click here to Skip to main content
15,902,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sockets - recv - Number of received bytes? Pin
Johnny ²11-Mar-03 21:40
Johnny ²11-Mar-03 21:40 
AnswerRe: Sockets - recv - Number of received bytes? Pin
Tim Smith12-Mar-03 2:03
Tim Smith12-Mar-03 2:03 
AnswerRe: Sockets - recv - Number of received bytes? Pin
Joseph Dempsey13-Mar-03 8:20
Joseph Dempsey13-Mar-03 8:20 
GeneralRe: Sockets - recv - Number of received bytes? Pin
Daniel Strigl13-Mar-03 8:34
Daniel Strigl13-Mar-03 8:34 
General"OnChar" Msg and Edit Control Pin
Gabor Kalman11-Mar-03 20:59
Gabor Kalman11-Mar-03 20:59 
GeneralRe: "OnChar" Msg and Edit Control Pin
Brian Shifrin12-Mar-03 0:34
Brian Shifrin12-Mar-03 0:34 
GeneralRe: "OnChar" Msg and Edit Control Pin
Gabor Kalman12-Mar-03 12:44
Gabor Kalman12-Mar-03 12:44 
GeneralMAPI problem Pin
chepuri_uk11-Mar-03 20:39
chepuri_uk11-Mar-03 20:39 
The following code is from MSDN MAPI sample:

after compiling and running it's giving error:

Any help on this...

#include "stdafx.h"
#include "mapix.h"
#include "mapiutil.h"

HRESULT GetMAPIStatus(LPMAPISTATUS *pStatus, LPMAPISESSION pSession);

int main(int argc, char* argv[])
{
LPMAPISESSION pSession = NULL; //MAPI Session Pointer
LPMAPISTATUS pStat=NULL; //MAPI Status Pointer

HRESULT hRes = S_OK;

//Initialize MAPI.
hRes = MAPIInitialize(NULL);

//Log on to MAPI and get a session pointer.
hRes = MAPILogonEx(0, NULL, NULL, MAPI_LOGON_UI | MAPI_NEW_SESSION, &pSession);
//hRes = MAPILogonEx(0, "umakanthch", "chepuri_uk", MAPI_LOGON_UI | MAPI_NEW_SESSION, &pSession);

if (hRes == S_OK && pSession) //if logon OK get a status pointer.
{
//Call function to get the status pointer.
hRes = GetMAPIStatus(&pStat, pSession);

if(hRes == S_OK && pStat) //if we successfully got a status pointer call FlushQueues on it.
{
//Flush inbound and outbound messages.
hRes = pStat->FlushQueues(NULL, 0, NULL, FLUSH_UPLOAD | FLUSH_DOWNLOAD);
if(hRes == S_OK)
MessageBox(NULL, "FlushQueues OK!", "FlushQueues", MB_OK);
else
MessageBox(NULL, "FlushQueues Failed!", "FlushQueues", MB_OK);
}
else
MessageBox(NULL, "GetMAPIStatus Failed!", "FlushQueues", MB_OK);

pSession->Logoff(NULL, 0L, 0);
}
else
{
MessageBox(NULL, "MAPI Logon Failed!", "FlushQueues", MB_OK);
}

//Clean up pointers.
UlRelease(pStat);
UlRelease(pSession);
MAPIUninitialize();

// MessageBox(NULL, "End of MAPI ", "FlushQueues", MB_OK);

return 0;
}

/////////////////////////////////////////////////////////////////
// Gets the spooler's status object from the session status table.
/////////////////////////////////////////////////////////////////
HRESULT GetMAPIStatus(LPMAPISTATUS *pStat, LPMAPISESSION pSession)
{
LPMAPITABLE pTbl = NULL;
LPSRowSet pRow = NULL;
HRESULT hRes;
SRestriction sres;
SPropValue spv;
ULONG ulObjType;
int cbEID;
LPENTRYID pbEID;

const static SizedSPropTagArray(2,sptCols) = {2,PR_RESOURCE_TYPE,PR_ENTRYID};

if (FAILED(hRes = pSession -> GetStatusTable(0,&pTbl)))
{
MessageBox(NULL, "GetStatusTable Failed!", "GetStatusTable", MB_OK);
goto Quit;
}

sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE;
sres.res.resProperty.lpProp = &spv;

spv.ulPropTag = PR_RESOURCE_TYPE;
spv.Value.l = MAPI_SPOOLER;

if (FAILED(hRes = HrQueryAllRows(pTbl,
(LPSPropTagArray) &sptCols,
&sres,
NULL,
0,
&pRow)))
{
MessageBox(NULL, "HrQueryAllRows Failed!", "HrQueryAllRows", MB_OK);
goto Quit;
}

if (!pRow -> cRows || PR_ENTRYID != pRow -> aRow[0].lpProps[1].ulPropTag)
{

hRes = MAPI_E_NOT_FOUND;
MessageBox(NULL, "HrQueryAllRows Failed!", "HrQueryAllRows", MB_OK);
goto Quit;
}

hRes = pSession -> OpenEntry(pRow -> aRow[0].lpProps[1].Value.bin.cb,
(LPENTRYID)pRow -> aRow[0].lpProps[1].Value.bin.lpb,
NULL,
MAPI_BEST_ACCESS,
&ulObjType,
(LPUNKNOWN *)pStat);

if (FAILED(hRes))
{
hRes = hRes ? hRes : MAPI_E_INVALID_OBJECT;
MessageBox(NULL, "OpenEntry Failed1!", "OpenEntry1", MB_OK);
goto Quit;
}

/*if (FAILED(hRes) || MAPI_STATUS != ulObjType)
{
hRes = hRes ? hRes : MAPI_E_INVALID_OBJECT;
MessageBox(NULL, "OpenEntry Failed!", "OpenEntry", MB_OK);
goto Quit;
}*/

Quit:
if (pTbl)
pTbl -> Release();

FreeProws(pRow);
return hRes;
}


Thank you
GeneralTimer problems Pin
Dennis Kuppens11-Mar-03 20:17
Dennis Kuppens11-Mar-03 20:17 
GeneralRe: Timer problems Pin
KarstenK11-Mar-03 20:44
mveKarstenK11-Mar-03 20:44 
GeneralHelp..Help...!!!!!!!! Pin
Renjith Ramachandran11-Mar-03 19:21
Renjith Ramachandran11-Mar-03 19:21 
GeneralRe: Help..Help...!!!!!!!! Pin
Yuri Kreinin11-Mar-03 20:27
Yuri Kreinin11-Mar-03 20:27 
GeneralRe: Help..Help...!!!!!!!! Pin
valikac11-Mar-03 21:20
valikac11-Mar-03 21:20 
QuestionHow to read data from a ms-Word file? Pin
George211-Mar-03 18:34
George211-Mar-03 18:34 
AnswerRe: How to read data from a ms-Word file? Pin
Yuri Kreinin11-Mar-03 20:36
Yuri Kreinin11-Mar-03 20:36 
GeneralRe: How to read data from a ms-Word file? Pin
George211-Mar-03 20:44
George211-Mar-03 20:44 
QuestionHow to load the values from the resourse file? Pin
julych11-Mar-03 18:20
julych11-Mar-03 18:20 
AnswerRe: How to load the values from the resourse file? Pin
KarstenK11-Mar-03 20:47
mveKarstenK11-Mar-03 20:47 
GeneralGet the memory leak position Pin
novachen11-Mar-03 17:32
novachen11-Mar-03 17:32 
GeneralRe: Get the memory leak position Pin
567890123411-Mar-03 19:56
567890123411-Mar-03 19:56 
GeneralRe: Get the memory leak position Pin
Chris Losinger12-Mar-03 1:49
professionalChris Losinger12-Mar-03 1:49 
GeneralRunning inside the main loop under MFC Pin
brandon187911-Mar-03 17:31
brandon187911-Mar-03 17:31 
GeneralRe: Running inside the main loop under MFC Pin
567890123411-Mar-03 19:57
567890123411-Mar-03 19:57 
GeneralC++ object oriented programming question. Pin
trustno111-Mar-03 17:11
trustno111-Mar-03 17:11 
GeneralRe: C++ object oriented programming question. Pin
Christian Graus11-Mar-03 19:32
protectorChristian Graus11-Mar-03 19:32 

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.