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;
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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;
 
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
>


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.
 
S

Sue Mosher [MVP]

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;
 
M

MB34

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;
 
S

Sue Mosher [MVP]

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 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
V Why is "Value Required" checkbox greyed out for Dates? Outlook VBA and Custom Forms 2
B Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
S User Defined Fields adding new value (2) Using Outlook 0
C Copy Outlook contact field value to another field Outlook VBA and Custom Forms 1
M Outlook 2013 Replace Subject with Conversation (a "hidden" value). Outlook VBA and Custom Forms 0
S Find a cell value in excel using outlook vba Using Outlook 1
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
A How to assign the value returned by the regex execute function to a variable? Using Outlook 1
N Lookup Value From Excel and Reply With Matching Value Using Outlook 0
R User Defined Fields adding new value Using Outlook 3
C Copy Cell value from Excel and paste into current email Outlook VBA and Custom Forms 10

Similar threads

Top