?????? ??? ????? ??? ????? ???????? ???? ???? Outlook ??????? ????? ?? MAPI ?? 6.0 Visual C++

?????? ????????? ?????? ?????????
???? ???????: 304894 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

????? ???

???? ??? ??????? ????? ??????? PR_ENTRYID ??????? ???? ?? ?????? ????? ?? ????? MAPI ???? ???? ???? ???????? ???? ???? Outlook.

??????? ????

????? ????? ??? ??????? ????? ?? Microsoft Visual C++ ???? ??????? ???????:
  1. ??? Visual Studio ?????? ????? Win32 ???? ???? "OOMEntryID" ???? ??? ??????? Win32 ????? A.
  2. ??? ??? OOMEntryID.cpp ???????? ???????? ??????? ?? ??? ?????. ???? ?? ????? ?????? ??? Mso.dll ?? Msoutl.olb ??? ??? ??????? ?????? ????????? ????? ??.
    #include "stdafx.h"
    #include "edk.h"
    
    // Import Outlook object model.
    #define IMPPROPS rename_namespace("OL")
    // Define this according to the Outlook object model 
    // version you are compiling under.
    
    //#define OL2000 // Outlook 2000
    #define OL2002 // Outlook 2002 (2002)
    
    #if defined(OL2000)
      // TODO: Verify that the path to the file is correct.
      #import "c:\Program Files\Microsoft Office\Office\mso9.dll" IMPPROPS 
      #import "c:\Program Files\Microsoft Office\Office\msoutl9.olb" IMPPROPS
    #elif defined(OL2002)
      // TODO: Verify that the path to the file is correct.
      #import "c:\Program Files\Common Files\Microsoft Shared\Office10\mso.dll" IMPPROPS 
      #import "c:\Program Files\Microsoft Office\Office10\\msoutl.olb" IMPPROPS
    #endif
    
    struct StartOle 
    {
       StartOle() { CoInitialize(NULL); }
       ~StartOle() { CoUninitialize(); }
    } _inst_StartOle;
    
    
    void dump_com_error(_com_error &e)
    {
        _tprintf(_T("Oops - hit an error!\n"));
        _tprintf(_T("\a\tCode = %08lx\n"), e.Error());
        _tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
        _bstr_t bstrSource(e.Source());
        _bstr_t bstrDescription(e.Description());
        _tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource);
        _tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription);
    }
    
    using namespace OL;
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
      // MAPI session pointer.
      LPMAPISESSION  pSession = NULL; 
      HRESULT hRes = S_OK;
      
      // Please add error checking yourself.
    
      // Initialize MAPI.
      hRes = MAPIInitialize(NULL);
    
      // Log on to MAPI and get a session pointer.
      hRes = MAPILogonEx(0, NULL, NULL, MAPI_LOGON_UI, &pSession);
    
      // Open message store.
      ULONG      cbEIDStore = 0;
      LPENTRYID  lpEIDStore = NULL;
      IMsgStore  *pMsgStore;
    
      hRes = HrMAPIFindDefaultMsgStore(pSession, 
                      &cbEIDStore, 
                      &lpEIDStore);
    
      hRes = pSession->OpenMsgStore(NULL, 
                      cbEIDStore, 
                      lpEIDStore, 
                      NULL, 
                      MAPI_BEST_ACCESS, 
                      &pMsgStore);  
    
      // Open Inbox.
      ULONG        ulObjType;
      ULONG        cbEntryID;
      LPENTRYID    lppEntryID;
      IMAPIFolder  *lpFolder;
    
      hRes = pMsgStore->GetReceiveFolder(NULL, 
                         NULL, 
                         &cbEntryID, 
                         &lppEntryID, 
                         NULL);
    
      hRes = pMsgStore->OpenEntry(cbEntryID, 
                    lppEntryID, 
                    NULL, 
                    MAPI_BEST_ACCESS, 
                    &ulObjType, 
                    (LPUNKNOWN *)&lpFolder);
    
    
      // Get Inbox items.
      LPMAPITABLE  lpContentsTable = NULL;
      LPSRowSet    pRows = NULL;
      enum {ePR_SUBJECT, ePR_ENTRYID,  NUM_COLS};
      static SizedSPropTagArray(NUM_COLS,sptCols) 
      = {NUM_COLS, PR_SUBJECT, PR_ENTRYID};
      
    
      hRes = lpFolder->GetContentsTable(0, 
                        &lpContentsTable);
    
      hRes = HrQueryAllRows(lpContentsTable, 
                  (LPSPropTagArray) &sptCols, 
                  NULL, 
                  NULL, 
                  0, 
                  &pRows);
      
      if (pRows->cRows > 0) // Make sure there is at least one message.
      {
        // Get the first item in the Inbox and get its entry ID.
        IMessage    *lpMessage;
        LPSPropValue  pspvEID = NULL;
    
        hRes = pMsgStore->OpenEntry(pRows->aRow[0].lpProps[ePR_ENTRYID].Value.bin.cb, 
                                 (LPENTRYID)pRows->aRow[0].lpProps[ePR_ENTRYID].Value.bin.lpb, 
                                 NULL, 
                                 MAPI_BEST_ACCESS, 
                                 &ulObjType, 
                                 (LPUNKNOWN *)&lpMessage);
        
        hRes = HrGetOneProp(lpMessage, 
                  PR_ENTRYID, 
                  &pspvEID);
        
        char szEID[1001];
        HexFromBin(pspvEID[0].Value.bin.lpb, 
                   pspvEID[0].Value.bin.cb, 
                   szEID);
    
        // Open Outlook item using the entry ID we got from MAPI.
    
        try{
          OL::_ApplicationPtr  pOutlook("Outlook.Application");
          OL::_NameSpacePtr    pNameSpace = pOutlook->GetNamespace("MAPI");
          OL::_MailItemPtr     pMailItem = NULL;
    
          pMailItem = pNameSpace->GetItemFromID(szEID, vtMissing);
          if (pMailItem)
          {
            // Display message.
            pMailItem->Display(vtMissing);
          }
        } 
    
        catch (_com_error &e)
        {
          dump_com_error(e);
        }
    
        UlRelease(lpMessage);
      }
      else
      {
        MessageBox(NULL, 
               "There are no messages in the inbox", 
               "Open Item", 
               MB_OK);
      }
    
      pSession->Logoff(NULL, 0L, 0);
    
      FreeProws(pRows);
      UlRelease(lpContentsTable);
      UlRelease(lpFolder);
      UlRelease(pMsgStore);
      UlRelease(pSession);
    
      return 0;
    } 
    					
  3. ?? ??????? ??????? ???? ??? ???????. ???? ??? ????? ??????? ?????? ??? ?? ????? ??????? ??????.

    ???? ??????? ??????? ????? ?????? ????? ???????.
    MSVCRT.LIB addrLkup.lib edkguid.lib edkdebug.lib edkmapi.lib edkutils.lib mapi32.lib
    						
    ?????? ????? ?????? ????? libcd.lib libc.lib.

    ???? ???? ?????? ??????? ???????.
  4. ????? ?? ?? ?????? ???????.
  5. ???? ??? ??????? ?????? ?? ???? ??????.

?????

????? ?? ?????????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
259298????? ??????? "????? ????" Outlook ?? Visual C++ ???????? ????? #import

???????

???? ???????: 304894 - ????? ??? ??????: 24/????/1428 - ??????: 5.5
????? ???
  • ????? ????? ??????? ??????? ?? Microsoft
  • Microsoft Outlook 2000
  • Microsoft Outlook 2000 Service Pack 1
  • Microsoft Outlook 2002 Standard Edition
  • Microsoft Visual Studio 6.0 Enterprise Edition
????? ??????: 
kbmt kbemail kbopenfile kbprogramming kbhowto kbmsg KB304894 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????304894

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com