View Single Post
  #5  
Old July 9th 09, 03:14 PM posted to microsoft.public.outlook.program_vba
MB34
external usenet poster
 
Posts: 15
Default Obtain property value by name

On Jul 8, 2:32 pm, "Sue Mosher [MVP]" wrote:
Or use Item.ItemProperties.Item("property name") for simple, non-object
properties.


Thanks, Michael and Sue...

Quote:
The Delphi Outlook object model does not expose the ItemProperties
either.
In the included Outlook2000.pas file, ItemProperties is not exposed so
I am able to get
it by using the code below instead of either modifying the
Outlook2000.pas file or importing
the Outlook TLB on my system.

const
EmptyDispParams: TDispParams = (rgvarg: nil; rgdispidNamedArgs: nil;
cArgs: 0; cNamedArgs: 0);

var
intLCID: Integer;

function GetDispId(const Obj: IDispatch; const Member: WideString;
DispIdPtr: PInteger): Boolean;
begin
Result := Succeeded(Obj.GetIdsOfNames(GUID_NULL, @Member, 1,
intLCID, DispIdPtr));
end;

function InvokePropertyGet(const Obj: IDispatch; Name:
WideString):Variant;
var
TheDispId, ArgErr: Integer;
DispParams: TDispParams;
begin
if GetDispId(Obj, Name, @TheDispId) then
begin
DispParams := EmptyDispParams;
OleCheck(Obj.Invoke(TheDispId,
GUID_NULL,
intLCID,
DISPATCH_PROPERTYGET,
DispParams,
@Result,
nil,
@ArgErr));
end;
end;


// Usage:

var
AApptCompareFieldValue: Variant;
OutlookPropertyName: WideString;
begin
intLCID := LOCALE_USER_DEFAULT;
OutlookPropertyName := 'LastModificationTime';
AApptCompareFieldValue := InvokePropertyGet(AOutlookAppointmentItem,
OutlookPropertyName);
Showmessage(AApptCompareFieldValue);
end;
Ads