Board index » delphi » Retrieving Outlook Task StartDate property via HrGetOneProp

Retrieving Outlook Task StartDate property via HrGetOneProp


2005-06-17 11:22:14 PM
delphi85
Hello,
I've been using Extended MAPI to get properties from
Outlook tasks and this has been working fine...
However, I have been having problems trying to retrieve
the StartDate and EndDate properties of a task using
the same code that worked so successfully for the other
properties. The HrGetOneProp call in the following code
snippet fails. I used OutlookSpy to get the IDs for for
these properties the same way as I did for the other
properties that worked such as Status and PercentComplete.
const
TaskItem_GUID : TGUID = '{00062003-0000-0000-C000-000000000046}';
procedure ViewTaskStartDate(const AMsg : IMessage);
var
namProp:array[0..0] of TMAPINAMEID;
Names:array[0..0] of PMAPINAMEID;
namTag : PSPropTagArray;
PR_PROPERTY : ULONG;
assContProp : PSPropValue;
begin
with namProp[0] do
begin
lpguid := @TaskItem_GUID;
ulKind := MNID_ID;
Kind.lID := $8104; // StartDate property ID
end;
Names[0] := @namProp[0];
if S_OK = AMsg.GetIDsFromNames(1, Names[0], MAPI_CREATE, namTag) then
try
PR_PROPERTY := PT_SYSTIME or namTag^.aulPropTag[0];
if S_OK = HrGetOneProp(AMsg, PR_PROPERTY, assContProp) then
begin
try
// We've got the property...
// <do stuff with it>
finally
MAPIFreeBuffer(assContProp);
end;
end
else
// This is what happens...
MessageDlg('HrGetOneProp failed.', mtError, [mbOK], 0);
finally
MAPIFreeBuffer(namTag);
end
end;
Does anyone have any ideas ?
Thanks in advance,
Lurkio
 
 

Re:Retrieving Outlook Task StartDate property via HrGetOneProp

Looks perfectly fine to me. What is the error? Is the property tag the same
as shown by OutlookSpy? Are you sure that particular task has the Start
propetty? Unless you explicitly set it in the UI, tasks do not have start
dates.
Dmitry Streblechenko (MVP)
www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Lurkio" <spam?@no.thanks>writes
Quote
Hello,

I've been using Extended MAPI to get properties from
Outlook tasks and this has been working fine...

However, I have been having problems trying to retrieve
the StartDate and EndDate properties of a task using
the same code that worked so successfully for the other
properties. The HrGetOneProp call in the following code
snippet fails. I used OutlookSpy to get the IDs for for
these properties the same way as I did for the other
properties that worked such as Status and PercentComplete.

const
TaskItem_GUID : TGUID = '{00062003-0000-0000-C000-000000000046}';

procedure ViewTaskStartDate(const AMsg : IMessage);
var
namProp:array[0..0] of TMAPINAMEID;
Names:array[0..0] of PMAPINAMEID;
namTag : PSPropTagArray;
PR_PROPERTY : ULONG;
assContProp : PSPropValue;
begin
with namProp[0] do
begin
lpguid := @TaskItem_GUID;
ulKind := MNID_ID;
Kind.lID := $8104; // StartDate property ID
end;

Names[0] := @namProp[0];
if S_OK = AMsg.GetIDsFromNames(1, Names[0], MAPI_CREATE, namTag) then
try
PR_PROPERTY := PT_SYSTIME or namTag^.aulPropTag[0];

if S_OK = HrGetOneProp(AMsg, PR_PROPERTY, assContProp) then
begin
try
// We've got the property... // <do stuff with it>
finally
MAPIFreeBuffer(assContProp);
end; end
else
// This is what happens...
MessageDlg('HrGetOneProp failed.', mtError, [mbOK], 0);

finally
MAPIFreeBuffer(namTag);
end
end;

Does anyone have any ideas ?

Thanks in advance,

Lurkio
 

Re:Retrieving Outlook Task StartDate property via HrGetOneProp

Dmitry Streblechenko writes:
Quote
Looks perfectly fine to me. What is the error? Is the property tag the same
as shown by OutlookSpy? Are you sure that particular task has the Start
property? Unless you explicitly set it in the UI, tasks do not have start
dates.
Thanks Dmitry, you were right. The task not having the StartDate property set
in the UI was the problem. The code now works as expected.