public final class MapiContact extends MapiMessageItemBase
This class serves as a wrapper for MapiMessage to simplify the process of handling contact information
from MAPI properties. It provides a more intuitive interface for accessing and manipulating contact data
within the MAPI message.
Example:
// Load the MAPI message from a file
MapiMessage msg = MapiMessage.load("contact.msg");
// Check if the loaded message is a supported contact type
if (msg.getSupportedType() == MapiItemType.Contact) {
// Convert the MAPI message to a MapiContact object
MapiContact mapiContact = (MapiContact) msg.toMapiMessageItem();
// Display some contact info
System.out.println(mapiContact.getNameInfo().getDisplayName());
System.out.println(mapiContact.getElectronicAddresses().getEmail1().getEmailAddress());
}
attachments, namedPropertyMappingStorage, objectsToDispose, recipients| Constructor and Description |
|---|
MapiContact()
Initializes a new instance of the
MapiContact class |
MapiContact(String displayName,
String electonicAddress)
Initializes a new instance of the
MapiContact class. |
MapiContact(String displayName,
String electonicAddress,
String companyName)
Initializes a new instance of the
MapiContact class. |
MapiContact(String displayName,
String electonicAddress,
String companyName,
String primaryTelephoneNumber)
Initializes a new instance of the
MapiContact class. |
| Modifier and Type | Method and Description |
|---|---|
static MapiContact |
fromVCard(InputStream stream)
Reads
MapiContact from the specified stream containing vCard. |
static MapiContact |
fromVCard(InputStream stream,
Charset encoding)
Reads
MapiContact from the specified stream containing vCard. |
static MapiContact |
fromVCard(String filePath)
Reads
MapiContact from the specified vCard file
The supported vCard versions are 2.1 and 3.0 |
static MapiContact |
fromVCard(String filePath,
Charset encoding)
Reads
MapiContact from the specified vCard file
The supported vCard versions are 2.1 and 3.0 |
MapiContactElectronicAddressPropertySet |
getElectronicAddresses()
Specify properties for up to three different
e-mail addresses
and three different fax addresses
|
MapiContactEventPropertySet |
getEvents()
Specify events associated with a contact
|
MapiContactNamePropertySet |
getNameInfo()
The properties are used to specify the name
of the person represented by the contact
|
MapiContactOtherPropertySet |
getOtherFields()
Specify other fields of conhtact.
|
MapiContactPersonalInfoPropertySet |
getPersonalInfo()
Specify other additional contact information
|
MapiContactPhoto |
getPhoto()
Contains contact photo
MapiContactPhoto. |
MapiContactPhysicalAddressPropertySet |
getPhysicalAddresses()
Specify three physical addresses:
Home Address, Work Address, and Other Address.
|
MapiContactProfessionalPropertySet |
getProfessionalInfo()
Properties are used to store professional
details for the person represented by the contact
|
MapiContactTelephonePropertySet |
getTelephones()
Specify telephone numbers
for the contact
|
MapiMessage |
getUnderlyingMessage()
Retrieves the underlying MapiMessage object.
|
void |
save(OutputStream stream)
Saves this
MapiContact into the given stream with vCard format. |
void |
save(OutputStream stream,
ContactSaveOptions saveOptions)
Saves this
MapiContact to the given stream using specified save options. |
void |
save(OutputStream stream,
int saveFormat)
Saves this
MapiContact to the given stream with a format using the default options. |
void |
save(String filePath)
Saves this
MapiContact to the vCard file with a default options. |
void |
save(String filePath,
ContactSaveOptions saveOptions)
Saves this
MapiContact into file using specified save options. |
void |
save(String filePath,
int saveFormat)
Saves this
MapiContact to the specified file with a format using the default options. |
void |
setBodyContent(String content,
int contentType)
Sets the content of the body.
|
void |
setElectronicAddresses(MapiContactElectronicAddressPropertySet value)
Specify properties for up to three different
e-mail addresses
and three different fax addresses
|
void |
setEvents(MapiContactEventPropertySet value)
Specify events associated with a contact
|
void |
setNameInfo(MapiContactNamePropertySet value)
The properties are used to specify the name
of the person represented by the contact
|
void |
setOtherFields(MapiContactOtherPropertySet value)
Specify other fields of conhtact.
|
void |
setPersonalInfo(MapiContactPersonalInfoPropertySet value)
Specify other additional contact information
|
void |
setPhoto(MapiContactPhoto value)
Contains contact photo
MapiContactPhoto. |
void |
setPhysicalAddresses(MapiContactPhysicalAddressPropertySet value)
Specify three physical addresses:
Home Address, Work Address, and Other Address.
|
void |
setProfessionalInfo(MapiContactProfessionalPropertySet value)
Properties are used to store professional
details for the person represented by the contact
|
void |
setTelephones(MapiContactTelephonePropertySet value)
Specify telephone numbers
for the contact
|
checkIsDisposed, close, createNamedProperty, dispose, getAttachments, getBilling, getBody, getBodyHtml, getBodyRtf, getBodyType, getCategories, getCompanies, getItemId, getMessageClass, getMileage, getNamedProperties, getNamedPropertyMapping, getProperty, getPropertyStream, getRecipients, getSensitivity, getSubject, getSubjectPrefix, getSubStorages, getSupportedType, initNamedPropertyMappingStorage, removeProperty, setBilling, setBody, setBodyContent, setBodyRtf, setBodyRtf, setCategories, setCompanies, setMessageClass, setMessageFlags, setMileage, setNamedPropertyMapping, setProperty, setRecipients, setSensitivity, setsIMapiMessageItemMembers, setSubjectcreateMapiNode, getCodePage, getProperties, getPropertyBoolean, getPropertyBytes, getPropertyDateTime, getPropertyInt32, getPropertyLong, getPropertyShort, getPropertyString, getPropertyString, isStoreUnicodeOk, setProperty, tryGetPropertyData, tryGetPropertyDateTime, tryGetPropertyInt32, tryGetPropertyLong, tryGetPropertyString, tryGetPropertyString, tryGetPropertyString, tryGetPropertyStringpublic MapiContact()
Initializes a new instance of the MapiContact class
public MapiContact(String displayName, String electonicAddress)
Initializes a new instance of the MapiContact class.
displayName - The display name.electonicAddress - The electonic address.public MapiContact(String displayName, String electonicAddress, String companyName)
Initializes a new instance of the MapiContact class.
displayName - The display name.electonicAddress - The electonic address.companyName - Name of the company.public MapiContact(String displayName, String electonicAddress, String companyName, String primaryTelephoneNumber)
Initializes a new instance of the MapiContact class.
displayName - The display name.electonicAddress - The electonic address.companyName - Name of the company.primaryTelephoneNumber - The telephone number.public final MapiContactNamePropertySet getNameInfo()
The properties are used to specify the name of the person represented by the contact
public final void setNameInfo(MapiContactNamePropertySet value)
The properties are used to specify the name of the person represented by the contact
public final MapiContactPersonalInfoPropertySet getPersonalInfo()
Specify other additional contact information
public final void setPersonalInfo(MapiContactPersonalInfoPropertySet value)
Specify other additional contact information
public final MapiContactProfessionalPropertySet getProfessionalInfo()
Properties are used to store professional details for the person represented by the contact
public final void setProfessionalInfo(MapiContactProfessionalPropertySet value)
Properties are used to store professional details for the person represented by the contact
public final MapiContactTelephonePropertySet getTelephones()
Specify telephone numbers for the contact
public final void setTelephones(MapiContactTelephonePropertySet value)
Specify telephone numbers for the contact
public final MapiContactElectronicAddressPropertySet getElectronicAddresses()
Specify properties for up to three different e-mail addresses and three different fax addresses
public final void setElectronicAddresses(MapiContactElectronicAddressPropertySet value)
Specify properties for up to three different e-mail addresses and three different fax addresses
public final MapiContactPhysicalAddressPropertySet getPhysicalAddresses()
Specify three physical addresses: Home Address, Work Address, and Other Address. One of the addresses can be marked as the Mailing Address
public final void setPhysicalAddresses(MapiContactPhysicalAddressPropertySet value)
Specify three physical addresses: Home Address, Work Address, and Other Address. One of the addresses can be marked as the Mailing Address
public final MapiContactEventPropertySet getEvents()
Specify events associated with a contact
public final void setEvents(MapiContactEventPropertySet value)
Specify events associated with a contact
public final MapiContactOtherPropertySet getOtherFields()
Specify other fields of conhtact.
public final void setOtherFields(MapiContactOtherPropertySet value)
Specify other fields of conhtact.
public final MapiContactPhoto getPhoto()
Contains contact photoMapiContactPhoto.
public final void setPhoto(MapiContactPhoto value)
Contains contact photoMapiContactPhoto.
public static MapiContact fromVCard(String filePath)
Reads MapiContact from the specified vCard file
The supported vCard versions are 2.1 and 3.0
filePath - A file name to read fromMapiContactArgumentException - filePath is null or emptypublic static MapiContact fromVCard(String filePath, Charset encoding)
Reads MapiContact from the specified vCard file
The supported vCard versions are 2.1 and 3.0
filePath - A file name to read fromencoding - File data encodingMapiContactArgumentException - filePath is null or emptypublic static MapiContact fromVCard(InputStream stream)
Reads MapiContact from the specified stream containing vCard.
The supported vCard versions are 2.1 and 3.0
stream - A stream to read fromMapiContactArgumentNullException - stream is nullNotSupportedException - stream does not support readingpublic static MapiContact fromVCard(InputStream stream, Charset encoding)
Reads MapiContact from the specified stream containing vCard.
The supported vCard versions are 2.1 and 3.0
stream - A stream to read fromencoding - Stream data encodingMapiContactArgumentNullException - stream is nullNotSupportedException - stream does not support readingpublic final MapiMessage getUnderlyingMessage()
MapiMessage object.
Retrieves the underlying MAPI message from a MapiContact object and prints out its message class.
// Retrieve the underlying MAPI message from the MapiContact object
MapiMessage msg = mapiContact.getUnderlyingMessage();
// Print out the message class of the MAPI message
// Will output XVHK4D9KDb.get(new byte[] { (byte)0xc6, (byte)0xa8, (byte)0x7f, (byte)0x5c, (byte)0xfd, (byte)0xfb, (byte)0xcd, (byte)0xa8, (byte)0xb2, (byte)0xec, (byte)0xa0 })
System.out.println(msg.getMessageClass());
public final void save(String filePath)
Saves this MapiContact to the vCard file with a default options.
The supported vCard version is 2.1
filePath - A vCard file nameArgumentException - filePath is null or emptypublic final void save(String filePath, int saveFormat)
Saves this MapiContact to the specified file with a format using the default options.
The supported save format is vCard.
filePath - A vCard file namesaveFormat - A save formatArgumentException - filePath is null or emptyNotSupportedException - the specified format is not supportedpublic final void save(String filePath, ContactSaveOptions saveOptions)
Saves this MapiContact into file using specified save options.
The supported save options is VCardSaveOptions
filePath - A vCard file namesaveOptions - A save optionsArgumentException - filePath is null or emptyArgumentNullException - saveOptions is nullNotSupportedException - some save option is not supportedpublic final void save(OutputStream stream)
Saves this MapiContact into the given stream with vCard format.
The supported vCard version is 2.1
stream - A stream to save toArgumentNullException - stream is nullNotSupportedException - stream does not support writingpublic final void save(OutputStream stream, int saveFormat)
Saves this MapiContact to the given stream with a format using the default options.
The supported save format is vCard
stream - A stream to save tosaveFormat - A save formatArgumentNullException - stream is nullNotSupportedException - stream does not support writingNotSupportedException - The specified format is not supportedpublic final void save(OutputStream stream, ContactSaveOptions saveOptions)
Saves this MapiContact to the given stream using specified save options.
The supported save options is VCardSaveOptions
stream - A stream to save tosaveOptions - A save optionsArgumentNullException - stream or saveOptions is nullNotSupportedException - stream does not support writingArgumentException - incorrect saveOptionsNotSupportedException - some save option is not supportedpublic void setBodyContent(String content, int contentType)
Sets the content of the body.
setBodyContent in class MapiMessageItemBasecontent - The content.contentType - Type of the content.
ArgumentNullException - throws if the specified content string is null or empty.Copyright (c) 2008-2024 Aspose Pty Ltd. All Rights Reserved.