A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Obtain property value by name



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 8th 09, 04:25 PM posted to microsoft.public.outlook.program_vba
MB34
external usenet poster
 
Posts: 15
Default Obtain property value by name

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;
  #2  
Old July 8th 09, 06:44 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Obtain property value by name



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 - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


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;

  #3  
Old July 8th 09, 08:17 PM posted to microsoft.public.outlook.program_vba
MB34
external usenet poster
 
Posts: 15
Default Obtain property value by name

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.
  #4  
Old July 8th 09, 08:32 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Obtain property value by name

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

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Michael Bauer [MVP - Outlook]" wrote in message
...


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 - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


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;



  #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;
  #6  
Old July 9th 09, 03:43 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Obtain property value by name

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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"MB34" wrote in message
...
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;



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting email address of To property in Outlook Inbox and From property in Outlook Outbox Omatase Outlook - General Queries 1 July 19th 07 01:04 PM
obtain last selected mail Steffen Heinzl Add-ins for Outlook 2 November 17th 06 02:20 PM
How to obtain the body of a temporary MailItem? IceKettle Add-ins for Outlook 0 November 7th 06 02:32 AM
how do i obtain an office outlook 2003 manual Jane & Izzy Outlook - General Queries 2 October 11th 06 02:54 PM
How do I set up/obtain a rolodex in outlook 2003? Working dude. Outlook - Using Contacts 1 July 7th 06 09:10 PM


All times are GMT +1. The time now is 10:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.