Home : Retrieving Additional Fields from a Contact Record When Accessing Exchange
Q53135 - HOWTO: Retrieving Additional Fields from a Contact Record When Accessing Exchange

Retrieving Additional Fields from a Contact Record When Accessing Exchange

 

The JebContact class is the wrapper of Exchange Contact. If you intend to retrieve additional contact fields other than those directly supported by the methods of JebContact, new methods can be added to JebContact for this purpose.

Prerequisites

  1. JDK 2.x or higher
  2. J-Integra
  3. MS Exchange Server Version 5.5 Service Pack 4 (or higher), MS Exchange 2000 Service Pack 3 (or higher), or MS Exchange 2003
  4. Ensure that you have installed the J-Integra license
  5. Make sure you have configured the Exchange Server

Add New Methods

  1. Find JebContact.java, which is in your \source\com\intrinsyc\jeb folder.

    For example,
    C:\jintegra\source\com\intrinsyc\jeb\JebContact.java

  2. Backup it by copying and pasting, and name the backup file as JebContact_backup.java.

  3. Open JebContact.java. Look up the property tag of field from the Appendix: CDO Contact Properties below, and add a new "get" method and a new "set" method to JebContact.java.

    For instance, to manipulate the Company Name field, look up the
    Appendix: CDO Contact Properties and you will see that CdoPR_COMPANY_NAME is the property tag of Company Name. Add the following getCompanyName and setCompanyName methods to your JebContact.java by copying and pasting.
/** 
* Returns the company name of this contact if it exists. An error will
* not be thrown for this.
*
* @returns String - Contains the company name if it exists or null otherwise
*/


public String
getCompanyName() {

Field fd = null;
String returnValue = null;

try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_COMPANY_NAME),
new FieldsProxy(_message.getFields()) );
returnValue = (String)fd.getValue();
} catch (Exception e) {
e.printStackTrace();
}

return returnValue;
}


/**
* Sets the value of the company name for this message. If the company name
* field does not exist, it will be added and have it's value set
*
* @param companyName - The name to set for this contact
* @throws JebException - If the name cannot be set or added
*/

public void
setCompanyName(String companyName) throws JebException {

Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_COMPANY_NAME),
new FieldsProxy(_message.getFields()) );
if(fd == null) {
this.addFieldObject(new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_COMPANY_NAME),
companyName, new FieldsProxy(_message.getFields()) );
}
else {
fd.setValue(companyName);
}
} catch (Exception e) {
throw new JebException("Cannot setCompanyName:\n" + e);
}
}
  1. Compile the modified JebContact.java.

    C:\jintegra\source\com\intrinsyc\jeb
    >javac JebContact.java
  2. Go to \lib, and make a backup file of jeb.jar. Name the backup file as jeb_bk.jar.

    C:\jintegra\lib>copy jeb.jar jeb_bk.jar
  3. In \lib directory, create new directories and make the path structure be
    \lib\com\intrinsyc\jeb.

    C:\jintegra\lib>mkdir com
    C:\jintegra\lib>cd com
    C:\jintegra\lib\com>mkdir intrinsyc
    C:\jintegra\lib\com>cd intrinsyc
    C:\jintegra\lib\com\intrinsyc>mkdir jeb

    C
    :\jintegra\lib\com\intrinsyc\jeb>
  4. Move the newly compiled JebContact.class to \lib\com\intrinsyc\jeb.

    C:\jintegra\source\com\intrinsyc\jeb
    >move JebContact.class C:\jintegra\lib\com\intrinsyc\jeb
  5. Update jeb.jar with the newly compiled JebContact.class. Remember to reserve the path structure of JebContact.class as com\intrinsyc\jeb\JebContact.class.

    C:\jintegra\lib>jar uf jeb.jar com\intrinsyc\jeb\JebContact.class

  6. Now the methods getCompanyName and setCompanyName are ready to be used for manipulating Company Name just like the other "get" and "set" methods in JebContact.

    Refer to the Java examples in C:\jintegra\examples\java-exchange\applications\.

Note

The constants in JebContact.java are defined according to Appendix: CDO Contact Properties. You may need to add more such variables which depends on the fields that you need to manipulate.

private static final String CdoPropSetID3 = "0420060000000000C000000000000046";
private static final String CdoContact_EmailAddrType = "0x8082";
private static final String CdoContact_EmailEmailAddress = "0x8083";
private static final String CdoContact_EmailOriginalDisplayName = "0x8084";
private static final String CdoContact_FileAs = "0x8005";
private static final String CdoContact_FullNameAndCompany = "0x8019";

The ways to create and read the fields are very different which depends on what kinds of fields you are dealing with. For instance, CdoPR_BUSINESS_ADDRESS_COUNTRY and CdoPR_BUSINESS_ADDRESS_STREET are "Outlook contacts", and the way to populate them is different than the other kinds of fields. To do so, please refer to these two places:
1. the section "Create an Outlook Contact with CDO" from http://www.cdolive.com/cdo5.htm
2. the section "Read MAPI Properties" from http://www.smithfamily.com/Reference/CDOLive%20-%20Property%20Tags%20and%20Types.htm

More documentation is available from http://www.cdolive.com andhttp://msdn.microsoft.com/library/en-us/cdo/html/_olemsg_mapi_property_tags.asp

Appendix: CDO Contact Properties

The following table is a list of the most commonly used property tags of CDO contact:


CdoPropSetID3 = "0420060000000000C000000000000046"
CdoPropSetID4 = "0820060000000000C000000000000046"

Constant Hex ID Description
CdoPR_MESSAGE_DELIVERY_TIME &H0E060040 Item.CreationTime
CdoPR_MESSAGE_SIZE &H0E080003 Item.Size
CdoPR_SENSITIVITY &H00360003 Item.Sensitivity
CdoPR_MESSAGE_CLASS &H001A001F Item.MessageClass
CdoPR_IMPORTANCE &H00170003 Item.Importance
CdoPR_ENTRYID &H0FFF0102 Item.EntryID
CdoPR_BODY &H1000001F Item.Body
CdoContact_Categories CdoPropSetID5 & "Keywords" Item.Categories
CdoPR_DISPLAY_NAME &H3001001F Item.FullName
CdoPR_TITLE &H3A17001F Item.JobTitle
CdoPR_COMPANY_NAME &H3A16001F Item.CompanyName
CdoPR_DISPLAY_NAME_PREFIX &H3A45001E Item.Title
CdoPR_SURNAME &H3A11001E Item.LastName
CdoPR_MIDDLE_NAME &H3A44001F Item.MiddleName
CdoPR_GIVEN_NAME &H3A06001F Item.FirstName
CdoPR_GENERATION &H3A05001E Item.Suffix
CdoPR_BUSINESS_HOME_PAGE &H3A51001F Item.BusinessHomePage
CdoPR_PERSONAL_HOME_PAGE &H3A50001F Item.PersonalHomePage
CdoPR_FTP_SITE &H3A4C001E Item.FTPSite
CdoPR_INITIALS &H3A0A001E Item.Initials
CdoContact_WebPage CdoPropSetID3 & "0x802B" Item.WebPage
CdoContact_FileUnder CdoPropSetID3 & "0x8005" Item.FileAs
CdoContact_CompanyAndFullName CdoPropSetID3 & "0x8018" Item.CompanyAndFullName
CdoContact_CompanyLastFirstNoSpace CdoPropSetID3 & "0x8032" Item.CompanyLastFirstNoSpace
CdoContact_CompanyLastFirstSpaceOnly CdoPropSetID3 & "0x8033" Item.CompanyLastFirstSpaceOnly
CdoContact_FullNameAndCompany CdoPropSetID3 & "0x8019" Item.FullNameAndCompany
CdoContact_LastFirstAndSuffix CdoPropSetID3 & "0x8036" Item.LastFirstAndSuffix
CdoContact_LastFirstNoSpace CdoPropSetID3 & "0x8030" Item.LastFirstNoSpace
CdoContact_LastFirstNoSpaceCompany CdoPropSetID3 & "0x8034" Item.LastFirstNoSpaceCompany
CdoContact_LastFirstSpaceOnly CdoPropSetID3 & "0x8031" Item.LastFirstSpaceOnly
CdoContact_LastFirstSpaceOnlyCompany CdoPropSetID3 & "0x8035" Item.LastFirstSpaceOnlyCompany
CdoContact_LastNameAndFirstName CdoPropSetID3 & "0x8017" Item.LastNameandFirstName
CdoContact_EmailOriginalDisplayName CdoPropSetID3 & "0x8084" Item.EMail1DisplayName
CdoContact_EmailEmailAddress CdoPropSetID3 & "0x8083" Item.EMail1Address
CdoContact_EmailAddrType CdoPropSetID3 & "0x8082" Item.EMail1AddressType
CdoContact_EmailOriginalEntryID CdoPropSetID3 & "0x8085" Item.EMail1EntryID
CdoContact_Email2OriginalDisplayName CdoPropSetID3 & "0x8094" Item.EMail2DisplayName
CdoContact_Email2EmailAddress CdoPropSetID3 & "0x8093" Item.EMail2Address
CdoContact_Email2AddrType CdoPropSetID3 & "0x8092" Item.EMail2AddressType
CdoContact_Email2OriginalEntryID CdoPropSetID3 & "0x8095" Item.EMail2EntryID
CdoContact_Email3OriginalDisplayName CdoPropSetID3 & "0x80A4" Item.EMail3DisplayName
CdoContact_Email3EmailAddress CdoPropSetID3 & "0x80A3" Item.EMail3Address
CdoContact_Email3AddrType CdoPropSetID3 & "0x80A2" Item.EMail3AddressType
CdoContact_Email3OriginalEntryID CdoPropSetID3 & "0x80A5" Item.EMail3EntryID
CdoContact_SelectedAddress CdoPropSetID3 & "0x8022" Item.SelectedMailingAddress:
0 = None
1 = Home
2 = Business
3 = Other
CdoPR_ASSISTANT_TELEPHONE_NUMBER &H3A2E001F Item.AssistantTelephoneNumber
CdoPR_BUSINESS_TELEPHONE_NUMBER &H3A08001F Item.BusinessTelephoneNumber
CdoPR_BUSINESS2_TELEPHONE_NUMBER &H3A1B001F Item.Business2TelephoneNumber
CdoPR_BUSINESS_FAX_NUMBER &H3A24001F Item.BusinessFaxNumber
CdoPR_CALLBACK_TELEPHONE_NUMBER &H3A02001F Item.CallbackTelephoneNumber
CdoPR_CAR_TELEPHONE_NUMBER &H3A1E001F Item.CarTelephoneNumber
CdoPR_COMPANY_MAIN_PHONE_NUMBER &H3A57001F Item.CompanyMainTelephoneNumber
CdoPR_HOME_TELEPHONE_NUMBER &H3A09001F Item.HomeTelephoneNumber
CdoPR_HOME2_TELEPHONE_NUMBER &H3A2F001F Item.Home2TelephoneNumber
CdoPR_HOME_FAX_NUMBER &H3A25001F Item.HomeFaxNumber
CdoPR_ISDN_NUMBER &H3A2D001F Item.ISDNNumber
CdoPR_MOBILE_TELEPHONE_NUMBER &H3A1C001F Item.MobileTelephoneNumber
CdoPR_OTHER_TELEPHONE_NUMBER &H3A1F001F Item.OtherTelephoneNumber
CdoPR_PRIMARY_FAX_NUMBER &H3A23001F Item.OtherFaxNumber
CdoPR_PAGER_TELEPHONE_NUMBER &H3A21001F Item.PagerNumber
CdoPR_PRIMARY_TELEPHONE_NUMBER &H3A1A001F Item.PrimaryTelephoneNumber
CdoPR_RADIO_TELEPHONE_NUMBER &H3A1D001F Item.RadioTelephoneNumber
CdoPR_TELEX_NUMBER &H3A2C001F Item.TelexNumber
CdoPR_TTYTDD_PHONE_NUMBER &H3A4B001F Item.TTYTDDTelephoneNumber
CdoPR_POSTAL_ADDRESS &H3A15001F Item.MailingAddress
CdoPR_LOCALITY &H3A27001F Item.MailingAddressCity
CdoPR_BUSINESS_ADDRESS_COUNTRY &H3A26001E Item.MailingAddressCountry
CdoPR_POSTAL_CODE &H3A2A001E Item.MailingAddressPostalCode
CdoPR_BUSINESS_ADDRESS_POST_OFFICE_BOX &H3A2B001E Item.MailingAddressPostOfficeBox
CdoPR_STATE_OR_PROVINCE &H3A28001E Item.MailingAddressState
CdoPR_STREET_ADDRESS &H3A29001F Item.MailingAddressStreet
CdoPR_HOME_ADDRESS_CITY &H3A59001E Item.HomeAddressCity
CdoPR_HOME_ADDRESS_STREET &H3A5D001E Item.HomeAddressStreet
CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE &H3A5C001E Item.HomeAddressState
CdoPR_HOME_ADDRESS_COUNTRY &H3A5A001E Item.HomeAddressCountry
CdoPR_HOME_ADDRESS_POST_OFFICE_BOX &H3A5E001E Item.HomeAddressPostOfficeBox
CdoPR_HOME_ADDRESS_POSTAL_CODE &H3A5B001E Item.HomeAddressPostalCode
CdoPR_OTHER_ADDRESS_CITY &H3A5F001E Item.OtherAddressCity
CdoPR_OTHER_ADDRESS_STREET &H3A63001E Item.OtherAddressStreet
CdoPR_OTHER_ADDRESS_STATE_OR_PROVINCE &H3A62001E Item.OtherAddressState
CdoPR_OTHER_ADDRESS_COUNTRY &H3A60001E Item.OtherAddressCountry
CdoPR_OTHER_ADDRESS_POSTAL_CODE &H3A61001E Item.OtherAddressPostalCode
CdoPR_OTHER_ADDRESS_POST_OFFICE_BOX &H3A64001E Item.OtherAddressPostOfficeBox
CdoContact_HomeAddress CdoPropSetID3 & "0x801A" Item.HomeAddress
CdoContact_BusinessAddress CdoPropSetID3 & "0x801B" Item.BusinessAddress
CdoContact_OtherAddress CdoPropSetID3 & "0x801C" Item.OtherAddress
CdoContact_BusinessAddressCity CdoPropSetID3 & "0x8046" Item.BusinessAddressCity
CdoContact_BusinessAddressStreet CdoPropSetID3 & "0x8045" Item.BusinessAddressStreet
CdoContact_BusinessAddressState CdoPropSetID3 & "0x8047" Item.BusinessAddressState
CdoContact_BusinessAddressCountry CdoPropSetID3 & "0x8049" Item.BusinessAddressCountry
CdoContact_BusinessAddressPostalCode CdoPropSetID3 & "0x8048" Item.BusinessAddressPostalCode
CdoContact_BusinessAddressPostOfficeBox CdoPropSetID3 & "0x804A" Item.BusinessAddressPostOfficeBox
CdoPR_DEPARTMENT_NAME &H3A18001F Item.Department
CdoPR_MANAGER_NAME &H3A4E001F Item.ManagerName
CdoPR_OFFICE_LOCATION &H3A19001F Item.Location
CdoPR_ASSISTANT &H3A30001F Item.AssistantName
CdoPR_PROFESSION &H3A46001F Item.Profession
CdoPR_NICKNAME &H3A4F001F Item.NickName
CdoPR_BIRTHDAY &H3A420040 Item.Birthday
CdoPR_SPOUSE_NAME &H3A48001F Item.SpouseName
CdoPR_WEDDING_ANNIVERSARY &H3A410040 Item.Anniversary
CdoPR_ACCOUNT &H3A00001E Item.Account
CdoPR_COMPUTER_NETWORK_NAME &H3A49001E Item.ComputerNetworkName
CdoPR_CHILDRENS_NAMES &H3A58101E Item.Children
CdoPR_CUSTOMER_ID &H3A4A001E Item.CustomerID
CdoPR_GENDER &H3A4D0002 Item.Gender:
0 = Unspecified
1 = Female
2 = Male
CdoPR_GOVERNMENT_ID_NUMBER &H3A07001E Item.GovernmentIDNumber
CdoPR_HOBBIES &H3A43001E Item.Hobby
CdoPR_LANGUAGE &H3A0C001E Item.Language
CdoPR_LOCATION &H3A0D001E Item.OfficeLocation
CdoPR_ORGANIZATIONAL_ID_NUMBER &H3A10001E Item.OrganizationalIDNumber
CdoPR_REFERRED_BY_NAME &H3A47001E Item.ReferredBy
CdoContact_BillingInformation CdoPropSetID4 & "0x8535" Item.BillingInformation
CdoContact_InternetFreeBusyAddress CdoPropSetID3 & "0x80D8" Item.InternetFreeBusyAddress
CdoContact_Mileage CdoPropSetID4 & "0x8534" Item.Mileage
CdoContact_UserField1 CdoPropSetID3 & "0x804F" Item.UserField1
CdoContact_UserField2 CdoPropSetID3 & "0x8050" Item.UserField2
CdoContact_UserField3 CdoPropSetID3 & "0x8051" Item.UserField3
CdoContact_UserField4 CdoPropSetID3 & "0x8052" Item.UserField4
CdoContact_YomiCompanyName CdoPropSetID3 & "0x802E" Item.YomiCompanyName
CdoContact_YomiFirstName CdoPropSetID3 & "0x802C" Item.YomiFirstName
CdoContact_YomiLastName CdoPropSetID3 & "0x802D" Item.YomiLastName

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 9/25/2006.
Last Modified by J-Integra KB Admin.
Article has been viewed 5385 times.
Rated 6 out of 10 based on 31 votes.
Print Article
Email Article