任何人都知道如何找到.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