CDO 1.21 AddressEntry.Fields

G

Guest

Hello

I am trying to read information from the GAL using C# .NET. I am able to return a list of all the addresses and names, however, when I walk through each address I cannot access the MAPI.AddressEntry.Fields(proptag) property. VS .NET will not allow the code to compile. I am looking to pull out more info than just the addresses and names. My environment consists of the following

CDO 1.2
Exchange 5.
Outlook 200
VS .NET 200

Here is the code

MAPI.SessionClass oSession = new MAPI.SessionClass()
oSession.Logon("OUTLOOK", System.Reflection.Missing.Value, true, true, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value)

MAPI.AddressList oAddressList = (MAPI.AddressList) oSession.GetAddressList(MAPI.CdoAddressListTypes.CdoAddressListGAL)
Console.WriteLine(oAddressList.Name)
MAPI.AddressEntries oAddressEntries = (MAPI.AddressEntries)oAddressList.AddressEntries

for(int j = 1; j <= (int)oAddressEntries.Count; j++

MAPI.AddressEntry oAddressEntry = (MAPI.AddressEntry)oAddressEntries.get_Item(j)


if(oAddressEntry.DisplayType.Equals(0) || oAddressEntry.DisplayType.Equals(6)

Console.WriteLine(" " + oAddressEntry.Name + " " + oAddressEntry.Fields)



If I try oAddressEntry.Fields(proptag) the code will not compile and will return this error
'MAPI.AddressEntry.Fields' denotes a 'property' where a 'method' was expecte

Any advice is greatly appreciated

Thanks
Mik
 
J

Jay B. Harlow [MVP - Outlook]

Mike,
Have you tried:

oAddressEntry.Fields.get_Item(proptag)

The following site provides a number of resources on using Outlook with
..NET.

http://www.microeye.com/resources/res_outlookvsnet.htm

Hope this helps
Jay

Mike said:
Hello,

I am trying to read information from the GAL using C# .NET. I am able to
return a list of all the addresses and names, however, when I walk through
each address I cannot access the MAPI.AddressEntry.Fields(proptag) property.
VS .NET will not allow the code to compile. I am looking to pull out more
info than just the addresses and names. My environment consists of the
following:
CDO 1.21
Exchange 5.5
Outlook 2002
VS .NET 2003

Here is the code:

MAPI.SessionClass oSession = new MAPI.SessionClass();
oSession.Logon("OUTLOOK", System.Reflection.Missing.Value, true, true,
System.Reflection.Missing.Value, false, System.Reflection.Missing.Value);
 
J

Jay B. Harlow [MVP - Outlook]

Mike,
I was basing my example on your example. Your example used get_Item on
AddressEntries, hence my example used get_Item on Fields. Neither collection
has a get_Item method per se.

However! Both Fields & AddressEntries have an Item property. The point I am
trying to make is that Fields may not have an indexer, (the parametized Item
property) that is usable from C#, hence your need to use the get_Item method
directly. Also word of warning Fields.Item takes two parameters! The second
one is optional.

Remember that CDO is not supported under .NET, your mileage may vary, I find
using CDO from VB.NET to be very usable, I have not attempted from C# yet. I
am able to use the Item property from VB.NET on the Fields collection.

Hope this helps
Jay


Mike said:
Jay,

The get_Item method is not a member of the Fields object, at least its not
an exposed member. I have explored the microeye site and cannot find
anything there.
 
G

Guest

Jay

Thanks for your advice - I am new to using CDO and I may end up switching this over to VB .NET

Thanks
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Redemption question 1

Top