Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Jul : Fun with extended MAPI
| Subject: | Fun with extended MAPI |
| Posted by: | "m.vanzeist" (m.vanzeist@nospam_home.nl) |
| Date: | Wed, 6 Jul 2005 15:08:11 |
Hi all,
i have a problem with extended mapi running under a service and temporary
profiles.
When creating the temporaryprofile and calling configureMsgService, i alwas
get the dialog to enter the servername (The field in the configuration
dialog is blank), i tripple checked and the servername is supplied.
The mailboxname is correctly displayed in the configuration dialog, just the
servername is blank!? when i enter the servername again in the configuration
dialog, everything works..
i tried PR_PROFILE_UNRESOLVED_SERVER and PR_PROFILE_HOME_SERVER but both
properties will popup the configuration dialog. when the service starts.
below is the code snippet i use
Does anyone have an answer?
Mario,
function TExtMAPI.CreateTemporaryProfile(Profile: string;ServerName
:string;MailBoxName :string): boolean;
const Columns : record
cValues : ULONG;
aulPropTag : array[0..1] of ULONG;
end =
(cValues: 2; aulPropTag : (PR_SERVICE_UID, PR_SERVICE_NAME));
var hr :HResult;
FServiceAdmin:IMsgServiceAdmin;
lppTable:IMAPITABLE;
pRows: PSRowSet;
lpProp : PSPropValueArray;
I:byte;
MsgStoreUID :PMAPIUID;
lppMAPIError: PMAPIError;
sres :TSRestriction;
spv :TSPropValue;
PropList :array[0..1] of TSPropValue;
begin
pRows:=nil;
lppTable:=nil;
MsgStoreUID:=nil;
lppMAPIError:=nil;
Result:=False;
hr:=S_OK;
try
hr:=MAPIAdminProfiles(0,FProfileAdmin);
if Failed(hr) then exit;
FProfileAdmin.DeleteProfile(PChar(Profile),0);
hr:=FProfileAdmin.CreateProfile(PChar(Profile), nil, 0, 0);
if Failed(hr) then exit;
hr:=FProfileAdmin.AdminServices(PChar(Profile),nil,0,0,FServiceAdmin);
if Failed(hr) then exit;
hr:=FServiceAdmin.CreateMsgService('MSEMS',nil,0,0);
if Failed(hr) then exit;
hr:=FServiceAdmin.GetMsgServiceTable(0,lppTable);
if Failed(hr) then exit;
sres.rt := RES_CONTENT;
sres.res.resContent.ulFuzzyLevel := FL_FULLSTRING;
sres.res.resContent.ulPropTag := PR_SERVICE_NAME;
sres.res.resContent.lpProp := @spv;
spv.ulPropTag := PR_SERVICE_NAME;
spv.Value.lpszA := 'MSEMS';
hr := HrQueryAllRows(lppTable,@Columns, @sres, nil, 0, pRows);
if Failed(hr) then exit;
MsgStoreUID:=PMAPIUID(pRows.aRow[0].lpProps[0].Value.bin.lpb);
PropList[1].ulPropTag := PR_PROFILE_UNRESOLVED_NAME;
PropList[1].Value.lpszA:=PChar(MailboxName);
PropList[0].ulPropTag := PR_PROFILE_UNRESOLVED_SERVER;
PropList[0].Value.lpszA:=PChar(Servername);
hr:=FServiceAdmin.ConfigureMsgService(MsgStoreUID,0, SERVICE_UI_ALLOWED,
2, PSPropValue(@PropList));
finally
Result:=not Failed(hr);
if Assigned(pRows) then FreePRows(pRows);
lppTable:=nil;
if not Result then begin
try
if Assigned(FServiceAdmin) then
FServiceAdmin.GetLastError(hr,0,lppMAPIError)
else if Assigned(FProfileAdmin) then
FProfileAdmin.GetLastError(hr,0,lppMAPIError);
if Assigned(lppMapiError) then
FLastError:=lppMapiError.lpszError;
finally
lppMAPIError:=nil;
end;
if Assigned(FProfileAdmin) then
FProfileAdmin.DeleteProfile(PChar(Profile),0);
end;
FServiceAdmin:=nil;
end;
end;