|
/**
* This is a wrapper class for Contact items. It exposes methods for easier access to fields/properties
* of a Contact item. Feel free to modify/extend this code to suit your needs.
*
* This wrapper class exposes only the most-commonly used contact properties. If there are any properties
* that you want included, let us know and we will include them for you.
*
* For more information of how fields/properties are set, refer to:
* http://www.cdolive.com/cdo10.htm
*
*/
import com.intrinsyc.cdo.*;
public class Contact extends MessageProxy{
//********** PROPERTY TAGS FOR ACCESSING CDO/MAPI FIELDS *************//
private static final String CdoPropSetID3 = "0420060000000000C000000000000046";
//private static final String CdoPropSetID3 = "0006200400000000C000000000000046";
private static final String CdoPropSetID5 = "2903020000000000C000000000000046";
// e-mail address 1
private static final String CdoContact_Email1AddrType = "0x8082";
private static final String CdoContact_Email1EmailAddress = "0x8083";
private static final String CdoContact_Email1DisplayNameSummary = "0x8084";
private static final String CdoContact_Email1DisplayNameDetailed = "0x8080";
// e-mail address 2
private static final String CdoContact_Email2AddrType = "0x8092";
private static final String CdoContact_Email2EmailAddress = "0x8093";
private static final String CdoContact_Email2DisplayNameSummary = "0x8094";
private static final String CdoContact_Email2DisplayNameDetailed = "0x8090";
// e-mail address 3
private static final String CdoContact_Email3AddrType = "0x80A2";
private static final String CdoContact_Email3EmailAddress = "0x80A3";
private static final String CdoContact_Email3DisplayNameSummary = "0x80A4";
private static final String CdoContact_Email3DisplayNameDetailed = "0x80A0";
// business address
private static final String CdoContact_BusinessAddressCity = "0x8046";
private static final String CdoContact_BusinessAddressStreet = "0x8045";
private static final String CdoContact_BusinessAddressState = "0x8047";
private static final String CdoContact_BusinessAddressCountry = "0x8049";
private static final String CdoContact_BusinessAddressPostalCode = "0x8048";
private static final String CdoContact_WebPage = "0x802B";
private static final String CdoContact_IMAddress = "0x8062";
private static final String CdoContact_UserField1 = "0x804F";
private static final String CdoContact_UserField2 = "0x8050";
private static final String CdoContact_UserField3 = "0x8051";
private static final String CdoContact_UserField4 = "0x8052";
private static final String CdoContact_Categories = "Keywords";
private static final String CdoContact_SelectedAddress = "0x8022";
private static final String CdoContact_FullNameAndCompany = "0x8019";
private static final String CdoContact_CompanyAndFullName ="0x8018";
private static final String CdoContact_FileAs = "0x8005";
private static final String CdoContact_FileUnder = "0x8005";
private static final String CdoContact_FileUnderID = "0x8006";
Message _message = null;
public Contact(Message message) {
this._message = message;
}
public String getEntryID() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_ENTRYID),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public String getFirstName() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_GIVEN_NAME),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setFirstName(String firstName) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_GIVEN_NAME),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_GIVEN_NAME),
firstName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(firstName);
}
} catch (Exception e) {
throw new Exception("Cannot setFirstName:\n" + e);
}
}
public String getMiddleName() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(CdoPropTags.CdoPR_MIDDLE_NAME),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setMiddleName(String middleName) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(CdoPropTags.CdoPR_MIDDLE_NAME),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_MIDDLE_NAME),
middleName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(middleName);
}
} catch (Exception e) {
throw new Exception("Cannot setMiddleName:\n" + e);
}
}
public String getLastName() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_SURNAME),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setLastName(String lastName) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_SURNAME),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_SURNAME),
lastName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(lastName);
}
} catch (Exception e) {
throw new Exception("Cannot setLastName:\n" + e);
}
}
public String getJobTitle() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_TITLE),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setJobTitle(String title) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_TITLE),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_TITLE),
title, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(title);
}
} catch (Exception e) {
throw new Exception("Cannot setLastName:\n" + e);
}
}
public void setOfficeLocation(String officeLocation) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OFFICE_LOCATION),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OFFICE_LOCATION),
officeLocation, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(officeLocation);
}
} catch (Exception e) {
throw new Exception("Cannot setOfficeLocation:\n" + e);
}
}
public String getOfficeLocation() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OFFICE_LOCATION),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setManagersName(String officeLocation) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MANAGER_NAME),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MANAGER_NAME),
officeLocation, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(officeLocation);
}
} catch (Exception e) {
throw new Exception("Cannot setManagersName:\n" + e);
}
}
public String getManagersName() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MANAGER_NAME),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
// e-mail address 1
public String getEmailAddress() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_Email1DisplayNameSummary,
new FieldsProxy(_message.getFields()));
if (fd == null) {
fd = this.getFieldObject(CdoContact_Email1EmailAddress,
new FieldsProxy(_message.getFields()));
}
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setEmailAddress(String email) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_Email1EmailAddress, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email1AddrType, new Integer(8), "SMTP", CdoPropSetID3);
fields.add(CdoContact_Email1DisplayNameSummary, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email1DisplayNameDetailed, new Integer(8), email, CdoPropSetID3);
} catch (Exception e) {
e.printStackTrace();
}
}
// e-mail address 2
public String getEmailAddress2() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_Email2DisplayNameSummary,
new FieldsProxy(_message.getFields()));
if (fd == null) {
fd = this.getFieldObject(CdoContact_Email2EmailAddress,
new FieldsProxy(_message.getFields()));
}
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setEmailAddress2(String email) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_Email2EmailAddress, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email2AddrType, new Integer(8), "SMTP", CdoPropSetID3);
fields.add(CdoContact_Email2DisplayNameSummary, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email2DisplayNameDetailed, new Integer(8), email, CdoPropSetID3);
} catch (Exception e) {
e.printStackTrace();
}
}
// e-mail address 3
public String getEmailAddress3() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_Email3DisplayNameSummary,
new FieldsProxy(_message.getFields()));
if (fd == null) {
fd = this.getFieldObject(CdoContact_Email3EmailAddress,
new FieldsProxy(_message.getFields()));
}
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setEmailAddress3(String email) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_Email3EmailAddress, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email3AddrType, new Integer(8), "SMTP", CdoPropSetID3);
fields.add(CdoContact_Email3DisplayNameSummary, new Integer(8), email, CdoPropSetID3);
fields.add(CdoContact_Email3DisplayNameDetailed, new Integer(8), email, CdoPropSetID3);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getBusinessPhoneNumber() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessPhoneNumber(String businessNumber) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER),
businessNumber,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(businessNumber);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessPhoneNumber:\n" + e);
}
}
public String getHomePhoneNumber() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomePhoneNumber(String homeNumber) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_TELEPHONE_NUMBER),
homeNumber,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(homeNumber);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeNumber:\n" + e);
}
}
public String getFileAs() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_FileAs, new FieldsProxy(
_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setFileAs(String fileAs) throws Exception {
/* ' Write Outlook "FileAs"
.Add CdoContact_FileUnder, vbString, _
objMessage.Subject, CdoPropSetID3
.Add CdoContact_FileUnderID, vbLong, _
&HFFFFFFFF, CdoPropSetID3
*/
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_FileUnder, new Integer(8), fileAs, CdoPropSetID3);
fields.add(CdoContact_FileUnderID, new Integer(3), new Integer(-1), CdoPropSetID3);
} catch (Exception e) {
e.printStackTrace();
}
}
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;
}
public void setCompanyName(String companyName) throws Exception {
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 Exception("Cannot setCompanyName:\n" + e);
}
}
public String getBusinessPhoneNumber2() throws Exception{
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS2_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setBusinessPhoneNumber2(String businessTelephoneNumber2) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS2_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS2_TELEPHONE_NUMBER),
businessTelephoneNumber2,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(businessTelephoneNumber2);
}
} catch (Exception e) {
throw new Exception("Cannot setbusinessTelephoneNumber2:\n" + e);
}
}
public String getBusinessFaxNumber() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_FAX_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setBusinessFaxNumber(String businessFaxNumber)
throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_FAX_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_BUSINESS_FAX_NUMBER),
businessFaxNumber,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(businessFaxNumber);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessFaxNumber:\n" + e);
}
}
public String getDisplayNamePrefix() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_DISPLAY_NAME_PREFIX),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
//set Anrede
public void setDisplayNamePrefix(String DisplayNamePrefix) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_DISPLAY_NAME_PREFIX),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_DISPLAY_NAME_PREFIX),
DisplayNamePrefix,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(DisplayNamePrefix);
}
} catch (Exception e) {
throw new Exception("Cannot setAnrede:\n" + e);
}
}
//get Fax2
public String getBusinessFaxNumber2() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_FAX_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setBusinessFaxNumber2(String BusinessFaxNumber2)
throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_FAX_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_FAX_NUMBER),
BusinessFaxNumber2, new FieldsProxy(_message
.getFields()));
} else {
fd.setValue(BusinessFaxNumber2);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessFaxNumber2:\n" + e);
}
}
public String getMobilePhoneNumber() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MOBILE_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setMobilePhoneNumber(String MobilePhoneNumber)
throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MOBILE_TELEPHONE_NUMBER),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_MOBILE_TELEPHONE_NUMBER),
MobilePhoneNumber,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(MobilePhoneNumber);
}
} catch (Exception e) {
throw new Exception("Cannot MobilePhoneNumber:\n" + e);
}
}
public String getBusinessAddressCity() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressCity,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessAddressCity(String busAddrCity) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_BusinessAddressCity,
new Integer(8),
busAddrCity,
CdoPropSetID3);
} catch (Exception e) {
throw new Exception("Cannot setBusinessAddressCity:\n" + e);
}
}
public String getBusinessAddressStreet() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressStreet,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessAddressStreet(String busAddrStreet) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressStreet,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
CdoContact_BusinessAddressStreet,
busAddrStreet,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(busAddrStreet);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessAddressStreet:\n" + e);
}
}
public String getBusinessAddressState() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
CdoContact_BusinessAddressState,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessAddressState(String busAddrState) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressState,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
CdoContact_BusinessAddressState,
busAddrState,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(busAddrState);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessAddressState:\n" + e);
}
}
public String getBusinessAddressCountry() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressCountry,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessAddressCountry(String busAddrCountry) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressCountry,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_BusinessAddressCountry,
busAddrCountry, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(busAddrCountry);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessAddressCountry:\n" + e);
}
}
public String getBusinessAddressPostalCode() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressPostalCode,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setBusinessAddressPostalCode(String busAddrPostalCode) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_BusinessAddressPostalCode,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_BusinessAddressPostalCode,
busAddrPostalCode,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(busAddrPostalCode);
}
} catch (Exception e) {
throw new Exception("Cannot setBusinessAddressPostalCode:\n" + e);
}
}
public String getWebPage() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
//CdoContact_WebPage,
new Integer(CdoPropTags.CdoPR_BUSINESS_HOME_PAGE),
new FieldsProxy(_message.getFields())
);
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setWebPage(String WebPage) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(CdoPropTags.CdoPR_BUSINESS_HOME_PAGE),
//CdoContact_WebPage,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(CdoPropTags.CdoPR_BUSINESS_HOME_PAGE),
//CdoContact_WebPage,
WebPage,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(WebPage);
}
} catch (Exception e) {
throw new Exception("Cannot setWebPage:\n" + e);
}
}
public String getIMAddress() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
CdoContact_IMAddress,
new FieldsProxy(_message.getFields())
);
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setIMAddress(String address) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
CdoContact_IMAddress,
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
CdoContact_IMAddress,
address,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(address);
}
} catch (Exception e) {
throw new Exception("Cannot setIMAddress:\n" + e);
}
}
public String getComment() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_BODY),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setComment(String text) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_BODY),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_BODY), text,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(text);
}
} catch (Exception e) {
throw new Exception("Cannot setText:\n" + e);
}
}
public String getCategoriesEx() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
CdoContact_Categories,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setCategoriesEx(String[] Categories) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_Categories,
new Integer(8192),
Categories,
CdoPropSetID5);
} catch (Exception e) {
throw new Exception("Cannot setCategories:\n" + e);
}
}
public String getDepartmentName() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_DEPARTMENT_NAME),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setDepartmentName(String departmentName) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_DEPARTMENT_NAME),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_DEPARTMENT_NAME),
departmentName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(departmentName);
}
} catch (Exception e) {
throw new Exception("Cannot setAbteilung:\n" + e);
}
}
// home address details
public String getHomeAddressStreet() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STREET),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomeAddressStreet(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STREET),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STREET),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeAddrStreet:\n" + e);
}
}
public String getHomeAddressCity() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_CITY),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomeAddressCity(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_CITY),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_CITY),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeAddrStreet:\n" + e);
}
}
public String getHomeAddressState() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomeAddressState(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeAddressState:\n" + e);
}
}
public String getHomeAddressCountry() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_COUNTRY),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomeAddressCountry(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_COUNTRY),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_COUNTRY),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeAddressCountry:\n" + e);
}
}
public String getHomeAddressPostalCode() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_POSTAL_CODE),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setHomeAddressPostalCode(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_POSTAL_CODE),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_HOME_ADDRESS_POSTAL_CODE),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setHomeAddressPostalCode:\n" + e);
}
}
// other address details
public String getOtherAddressStreet() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STREET),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressStreet(String OtherAddrStreet) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STREET),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STREET),
OtherAddrStreet,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(OtherAddrStreet);
}
} catch (Exception e) {
throw new Exception("Cannot setOtherAddrStreet:\n" + e);
}
}
public String getOtherAddressCity() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_CITY),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressCity(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_CITY),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_CITY),
value,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setOtherAddrStreet:\n" + e);
}
}
public String getOtherAddressState() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STATE_OR_PROVINCE),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressState(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STATE_OR_PROVINCE),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_STATE_OR_PROVINCE),
value, new FieldsProxy(_message
.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot getOtherAddressState:\n" + e);
}
}
public String getOtherAddressCountry() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_COUNTRY),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressCountry(String value) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_COUNTRY),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this
.addFieldObject(
new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_COUNTRY),
value, new FieldsProxy(_message
.getFields()));
} else {
fd.setValue(value);
}
} catch (Exception e) {
throw new Exception("Cannot setOtherAddressCountry:\n" + e);
}
}
public String getOtherAddressPostalCode() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POSTAL_CODE),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressPostalCode(String otherAddrPostalCode) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POSTAL_CODE),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POSTAL_CODE),
otherAddrPostalCode, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(otherAddrPostalCode);
}
} catch (Exception e) {
throw new Exception("Cannot setOtherAddressPostalCode:\n" + e);
}
}
public String getOtherAddressPostOfficeBox() {
Field fd = null;
String returnValue = null;
try {
fd = this
.getFieldObject(
new Integer(
com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POST_OFFICE_BOX),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
//e.printStackTrace();
}
return returnValue;
}
public void setOtherAddressPostOfficeBox(String otherAddrPostOfficeBox)
throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POST_OFFICE_BOX),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(
new Integer(com.intrinsyc.cdo.CdoPropTags.CdoPR_OTHER_ADDRESS_POST_OFFICE_BOX),
otherAddrPostOfficeBox, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(otherAddrPostOfficeBox);
}
} catch (Exception e) {
throw new Exception("Cannot setOtherAddrPostfach:\n" + e);
}
}
public String getSelectedAddress() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_SelectedAddress,
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setSelectedAddress(String selectedAddress) throws Exception {
try {
Fields fields = new FieldsProxy(this._message.getFields());
fields.add(CdoContact_SelectedAddress,
new Integer(2), // 2 maps to integer
new Integer(selectedAddress),
CdoPropSetID3);
} catch (Exception e) {
throw new Exception("Cannot setPostanschrift:\n" + e);
}
}
public String getUserField1() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_UserField1, new FieldsProxy(
_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setUserField1(String UserField1) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_UserField1, new FieldsProxy(
_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_UserField1, UserField1,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(UserField1);
}
} catch (Exception e) {
throw new Exception("Cannot setUserField1:\n" + e);
}
}
public String getUserField2() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_UserField2, new FieldsProxy(
_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setUserField2(String UserField2) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_UserField2, new FieldsProxy(
_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_UserField2, UserField2,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(UserField2);
}
} catch (Exception e) {
throw new Exception("Cannot setUserField2:\n" + e);
}
}
public String getUserField3() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_UserField3, new FieldsProxy(
_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setUserField3(String UserField3) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_UserField3, new FieldsProxy(
_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_UserField3, UserField3,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(UserField3);
}
} catch (Exception e) {
throw new Exception("Cannot setUserField3:\n" + e);
}
}
public String getUserField4() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(CdoContact_UserField4, new FieldsProxy(
_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setUserField4(String UserField4) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(CdoContact_UserField4, new FieldsProxy(
_message.getFields()));
if (fd == null) {
this.addFieldObject(CdoContact_UserField4, UserField4,
new FieldsProxy(_message.getFields()));
} else {
fd.setValue(UserField4);
}
} catch (Exception e) {
throw new Exception("Cannot setUserField4:\n" + e);
}
}
public String getAccount() {
Field fd = null;
String returnValue = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_ACCOUNT),
new FieldsProxy(_message.getFields()));
returnValue = (String) fd.getValue();
} catch (Exception e) {
}
return returnValue;
}
public void setAccount(String account) throws Exception {
Field fd = null;
try {
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_ACCOUNT),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_ACCOUNT),
account, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(account);
}
} catch (Exception e) {
throw new Exception("Cannot setAccount:\n" + e);
}
}
public void save() throws Exception {
try {
if (this.getFileAs() == null) {
String fileAsName = "";
if (this.getLastName() != null) {
if (this.getFirstName() != null) {
fileAsName = this.getLastName() + ", " + this.getFirstName();
} else {
fileAsName = this.getLastName();
}
} else if (this.getFirstName() != null) {
fileAsName = this.getFirstName();
}
this.setFileAs(fileAsName);
}
String displayName = "";
if (this.getLastName() != null) {
if (this.getFirstName() != null) {
if (this.getMiddleName() != null) {
displayName = this.getFirstName() + " " + this.getMiddleName() + " " + this.getLastName();
} else {
displayName = this.getFirstName() + " " + this.getLastName();
}
} else {
displayName = this.getFirstName();
}
} else if (this.getFirstName() != null) {
displayName = this.getFirstName();
}
Field fd = null;
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_DISPLAY_NAME_W),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_DISPLAY_NAME_W),
displayName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(displayName);
}
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_NORMALIZED_SUBJECT_W),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_NORMALIZED_SUBJECT_W),
displayName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(displayName);
}
fd = this.getFieldObject(new Integer(CdoPropTags.CdoPR_SUBJECT_W),
new FieldsProxy(_message.getFields()));
if (fd == null) {
this.addFieldObject(new Integer(CdoPropTags.CdoPR_SUBJECT_W),
displayName, new FieldsProxy(_message.getFields()));
} else {
fd.setValue(displayName);
}
Fields fields = new FieldsProxy(this._message.getFields());
fields.add("0x8029", new Integer(3), new Integer(1), CdoPropSetID3);
_message.setType("IPM.Contact");
_message.update(new Boolean(true), new Boolean(true));
} catch (java.io.IOException e) {
throw new Exception("Cannot save contact:\n" + e);
}
}
//************* UTILITY METHODS ******************//
public Field getFieldObject(Object cdoPR_id, Fields fs) {
Field fd = null;
try {
fd = new FieldProxy(fs.getItem(cdoPR_id, CdoPropSetID3));
} catch (java.io.IOException e) {
}
return fd;
}
private void addFieldObject(Object cdoPR_id, String value, Fields fs) throws Exception {
Field fd = null;
try {
fd = new FieldProxy(fs.add(cdoPR_id, new Integer(
com.intrinsyc.cdo.CdoFieldType.CdoString), value,
CdoPropSetID3));
fd.setValue(value);
} catch (Exception e) {
throw new Exception("Cannot add Field to Fields collection:\n" + e);
}
}
}
|
|