.OutLook & Mapi problem
-
The following sample is MAPI from MSDN. While runnin this is giving error: Any help on this : #include "mapix.h" #include "mapiutil.h" #include HRESULT GetMAPIStatus(LPMAPISTATUS *pStatus, LPMAPISESSION pSession); int main(int argc, char* argv[]) { LPMAPISESSION pSession = NULL; //MAPI Session Pointer LPMAPISTATUS pStat=NULL; //MAPI Status Pointer LPMAPISUP pSupport=NULL; 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); 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; LPMESSAGE lpMsg = NULL; 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.ulPropTag = PR_STATUS; sres.res.resProperty.lpProp = &spv; spv.ulPropT