2014-07-03 31 views
-1

任何人都知道如何找到.PST和.OST文件位置特定配置文件使用MAPI在德爾福?outlook profile .PST和.OST文件位置使用MAPI在delphi

代碼:

我已經寫了下面的代碼找到.PST路徑。但我得到的錯誤「2147221233」在該行「HrgetoneProps」

FMapiSession := nil; 
    res := MAPILogonEx(0, 'Default Outlook Profile', nil, ulFlags, FMapiSession); 
if res = S_OK then 
    begin 
    res := MAPIAdminProfiles(0, ProfAdmin); 
    {$IFDEF DEBUG}CodeSite.Send('MAPIAdminProfiles'); {$ENDIF} 
    if res = S_OK then 
     begin 
     res := FMapiSession.AdminServices(0, ServAdmin); 
     if res = S_OK then 
      begin 
      res := ServAdmin.GetMsgServiceTable(0, Tbl); 
      if res = S_OK then 
       begin 
       res := Tbl.SetColumns(PSPropTagArray(@sptCols), 0); 
       if res = S_OK then 
        begin 
        sres.rt := RES_PROPERTY; 
        sres.res.resProperty.relop := RELOP_EQ; 
        sres.res.resProperty.ulPropTag := PR_SERVICE_NAME; 
        sres.res.resProperty.lpProp := @spv; 
        spv.ulPropTag := PR_SERVICE_NAME; 
        spv.Value.lpszA := 'MSUPST MS'; 
        res := HrQueryAllRows(Tbl, @sptCols, @sres, nil, 0, pRow); 
        if res = S_OK then 
         begin 
         for I := 0 to pRow.aRow[0].cValues - 1 do 
          begin 
          if (pRow.aRow[0].lpProps[I].ulPropTag = PR_SERVICE_UID) then 
           begin 
           MsgStoreUID := PMAPIUID(pRow.aRow[0].lpProps[I].Value.bin.lpb); 
           break; 
           end; 
          end; 
         res := ServAdmin.OpenProfileSection(MsgStoreUID, TGUID(nil^), 
          MAPI_Force_ACCESS or MAPI_MODIFY, ProfSect); 

         if res = S_OK then 
          begin 
          {$IFDEF DEBUG}CodeSite.Send('HrGetOneProp'); {$ENDIF} 
          res := HrGetOneProp(ProfSect, PR_PST_PATH, propVal); 
          if res = S_OK then 
           begin 
           Result := propVal^.Value.lpszA; 
           MAPIFreeBuffer(propVal); 
           end 
          end 
         else 
          begin 
          // ... 
          end; 
         FreePRows(pRow); 
         end; 
        end; 
       end; 
      end; 
     end; 
    end 

回答

1

您可以

  1. 解析存儲條目ID(其格式記錄在MSDN上 - 看看PR_STORE_ENTRYID在OutlookSpy中)。

  2. 查看配置文件(IMsgServiceAdmin.GetMsgServiceTable)中的所有服務提供者。對於使用PR_SERVICE_NAME =='MSPST MS'/'MSUPST MS'/'INTERSTOR'等的服務,請閱讀服務提供商(IMsgServiceAdmin.AdminProviders)的表,打開配置文件部分,閱讀PR_ENTRYID。使用IMAPISession :: CompareEntryIDs將條目ID與有問題的商店的條目ID進行比較。如果它們匹配,請閱讀PR_PST_PATH屬性。你可以在OutlookSpy中玩這個 - 點擊IMAPISession | AdminServices。

  3. 使用Redemption - 它暴露了RDOPstStore.PstPath和RDOExchangeStore.OstPath。

+0

我試過第二個選項。但它仍然無法獲得PR_PST_PATH。請您在delphi中分享代碼片段? – user3801413

+0

我無法分享我現有的代碼(它是商業項目的一部分)。發佈你現有的代碼,我會看看。 –

+0

我已經在上面添加了我的代碼。 – user3801413

相關問題