Obtain property value by name

Status
Not open for further replies.
M

MB34

Need to access Appointment property by propertyname.

How to do that?

Let's say I want to write a function and pass a property name and then

return the value:

{Delphi}

function getPropValue(Propname: String): Variant;

begin

Result := AppointmentItem. ?????

end;
 
You need to handle every supported case, e.g.:

Select Case Propname

Case "Start": getPropValue=Item.Start

Case "Subject": getPropValue=Item.Subject

End Select

Best regards

Michael Bauer

Am Wed, 8 Jul 2009 08:25:21 -0700 (PDT) schrieb MB34:


> Need to access Appointment property by propertyname.
> How to do that?

> Let's say I want to write a function and pass a property name and then
> return the value:
> {Delphi}
> function getPropValue(Propname: String): Variant;
> begin
> Result := AppointmentItem. ?????
> end;
 
> > Need to access Appointment property by propertyname.
> > How to do that?

>
> > Let's say I want to write a function and pass a property name and then
> > return the value:
> > {Delphi}
> > function getPropValue(Propname: String): Variant;
> > begin
> >   Result := AppointmentItem. ?????
> > end;



> You need to handle every supported case, e.g.:

> Select Case Propname
> Case "Start": getPropValue=Item.Start
> Case "Subject": getPropValue=Item.Subject
> End Select
>


You mean that there is no way without handling each property in a case

statement?

The Delphi Outlook object model does not expose the ItemProperties

either.
 
Or use Item.ItemProperties.Item("property name") for simple, non-object

properties.

Sue Mosher

"Michael Bauer " <mb@mvps.org> wrote in message

news:ne0ucmksj1gs$.6z1y7kf1zzby.dlg@40tude.net...

> You need to handle every supported case, e.g.:

> Select Case Propname
> Case "Start": getPropValue=Item.Start
> Case "Subject": getPropValue=Item.Subject
> End Select

> > Best regards
> Michael Bauer

> >

> Am Wed, 8 Jul 2009 08:25:21 -0700 (PDT) schrieb MB34:
>
> > Need to access Appointment property by propertyname.
> > How to do that?
>

>> Let's say I want to write a function and pass a property name and then
> > return the value:
> > {Delphi}
> > function getPropValue(Propname: String): Variant;
> > begin
> > Result := AppointmentItem. ?????
> > end;
 
On Jul 8, 2:32 pm, "Sue Mosher [MVP]" <sue...@turtleflock.com> wrote:
> Or use Item.ItemProperties.Item("property name") for simple, non-object
> properties.


Thanks, Michael and Sue...

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;
 
ItemProperties was added in a version after Outlook 2000. I don't remember

which. Please give your Outlook version whenever you post a new issue here;

it's almost always relevant.

Sue Mosher

"MB34" <mrbaseball34@hotmail.com> wrote in message

news:fe892923-4db8-4f1f-8570-ddad5bdb3685@t21g2000yqi.googlegroups.com...
> On Jul 8, 2:32 pm, "Sue Mosher [MVP]" <sue...@turtleflock.com> wrote:
> > Or use Item.ItemProperties.Item("property name") for simple, non-object
> > properties.


> Thanks, Michael and Sue...

>
> 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;
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
F Obtain Members of a Distribution List Outlook 2003 c# Outlook VBA and Custom Forms 1
J Using Access to obtain E-mail address Outlook VBA and Custom Forms 5
A How to obtain the Distribution List of a Sender Outlook VBA and Custom Forms 4
L How I can obtain the text storage in a textbox in outlook? Outlook VBA and Custom Forms 1
V Is there no way to obtain sender's emailid from outlook calender d Outlook VBA and Custom Forms 7
D Unable to change AppointmentItem.Start property Outlook VBA and Custom Forms 4
S Problem Accessing .MSG Property 'ImageNaturalHeight' Tag '0x80010003' Outlook VBA and Custom Forms 1
P MailItem.To Property with VBA not work Outlook VBA and Custom Forms 2
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
G Store.FilePath Property Outlook VBA and Custom Forms 4
W Appointment occurrences change the location property Using Outlook 0
oliv- property "is printed" or catching print events Outlook VBA and Custom Forms 2
B Assistance with Deprecated .Links Property Outlook VBA and Custom Forms 2
JorgeDario ¿What property of mailitem can be used like primary key? Outlook VBA and Custom Forms 6
M Accessing ExpiryTime property Outlook VBA and Custom Forms 1
M How to automatically refresh an appointment windows after changing the MessageClass property ? Outlook VBA and Custom Forms 4
R Vba Conversation Index property Using Outlook 0
H Calendar Folder property is empty Using Outlook 1
G run-time 438: object doesn't support this property or method Using Outlook 2
Commodore Calendar Folder property is missing - Event 27 Using Outlook 11
B Update Item.Subject property Using Outlook 1
S Custom property/functionality not stored when I publish to a Public Folder Using Outlook 7
T You must Provide a value for this property on powershell cmdlet Exchange Server Administration 3
S Saved Property of MailItem is copied Outlook VBA and Custom Forms 1
M MailItem object has no property for when a reply was sent Outlook VBA and Custom Forms 3
D Using the CurrentFolder property Outlook VBA and Custom Forms 3
S Property pages in Outlook 2010 Outlook VBA and Custom Forms 1
M Can't create new user property? Outlook VBA and Custom Forms 10
S Xref type property in an email header? Outlook VBA and Custom Forms 6
W Setting PR_CREATION_TIME property? Outlook VBA and Custom Forms 1
D Item Property CHange Outlook VBA and Custom Forms 4
W Using a PropertyAccessor custom datetime property in Views Outlook VBA and Custom Forms 3
J How do I access the AssignedTo property in an outlook 2007 task? Outlook VBA and Custom Forms 7
S User property for folder Outlook VBA and Custom Forms 2
T Setting a MAPI property of type PT_SYSTIME Outlook VBA and Custom Forms 4
E Displayname of User Property Outlook VBA and Custom Forms 7
E Displayname of User Property Outlook VBA and Custom Forms 7
M Can't change autoarchive property in Deleted Items folder BCM (Business Contact Manager) 1
C How do I grab a field property (like .value) so I can modify it via OL code? Outlook VBA and Custom Forms 4
T recipient email address is invalid, but resolved property is true Outlook VBA and Custom Forms 3
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 1
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 5
S Displaying Date Value In Formula Outlook VBA and Custom Forms 6
M copy field value to custom field Outlook VBA and Custom Forms 0
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
HappyDaddy007 "Size" on field chooser/column displaying incorrect value Using Outlook 3
V Why is "Value Required" checkbox greyed out for Dates? Outlook VBA and Custom Forms 2
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
S User Defined Fields adding new value (2) Using Outlook 0

Similar threads

Back
Top