State Field from Address book

  • Thread starter Thread starter Chetan Ashar
  • Start date Start date
C

Chetan Ashar

I have written a CDO script to get the list of employee's and which state
(in outlook address book) they belong, I access AddressEntry.Fields
collection to get the field object with Id of 974716958, which gives the
value of State field. Is there any other way i could get access to the state
field ???

Above mentioned method works fine but after its run in the task scheduler,
for some reason it does not get values for state, returns empty string.

Thanks in Advance.
 
Following is the pice of code used to get the State field through CDO.

Program function is to find out each user's out of office text in the
organization and display the state in which the employee belongs. I was
sucessfully able to get the Out of office text message through CDO and
publish it but state information just returns blank after running for a day
or two (Program runs as a scheduled task in the windows explorer).

'***************************************************************
' Field to browse through all the fields collection in the Address entry
object
Set objField = Nothing

' This code gets the Address Entry
Set objAddressEntry = objAddressEntries.Item(1)

' Create a MAPI Session
Set objUserSess = Nothing
Set objUserSess = CreateObject("MAPI.Session")

' Profile to log on
strProfileInfo = strUserHomeServer & Chr(10) & objAddressEntry.Name

' Actual logon happens here
objUserSess.Logon "", "", False, True, 0, False, strProfileInfo

' Browse through the entire collection of fields in AddressEntry object of
CDO
For each objField in objAddressEntry.Fields

' Get the state field , which has Id of 974716958
If objField.Id = 974716958 then
strState = objField.value
exit for
End if
Next
'***************************************************************

Please let me know on what object would i use in the Outlook object model

Thanks
Chetan

Ken Slovak - said:
You could use the Outlook object model instead of CDO code. What is
your CDO code?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Chetan Ashar said:
I have written a CDO script to get the list of employee's and which state
(in outlook address book) they belong, I access AddressEntry.Fields
collection to get the field object with Id of 974716958, which gives the
value of State field. Is there any other way i could get access to the state
field ???

Above mentioned method works fine but after its run in the task scheduler,
for some reason it does not get values for state, returns empty string.

Thanks in Advance.
 
I would try something like this to get the State in an AddressEntry
that is in the GAL:

Const CdoPR_STATE = &H3A28001E
strState = objAddressEntry.Fields(CdoPR_STATE).Value

Of course if there is no entry for the State property the Field won't
be there.

For State in the GAL you couldn't use the Outlook object model, that
would only work if the AddressEntry object was in the Contacts folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
Back
Top