任何人都知道如何找到.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
我試過第二個選項。但它仍然無法獲得PR_PST_PATH。請您在delphi中分享代碼片段? – user3801413
我無法分享我現有的代碼(它是商業項目的一部分)。發佈你現有的代碼,我會看看。 –
我已經在上面添加了我的代碼。 – user3801413