public final class ExchangeClient extends ExchangeClientBase
<p>The ExchangeClient class allows applications to manage E-Mail box in Microsoft Exchange Server by using WebDav Exchange Store Protocol.</p>
Constructor and Description |
---|
ExchangeClient(String mailboxUri,
com.aspose.ms.System.Net.ICredentials credentials)
Initialize a new instance of the class
ExchangeClient |
ExchangeClient(String mailboxUri,
String username,
String password)
Initialize a new instance of the class
ExchangeClient |
ExchangeClient(String mailboxUri,
String username,
String password,
String domain)
Initialize a new instance of the class
ExchangeClient |
Modifier and Type | Method and Description |
---|---|
String |
appendMessage(String folder,
MailMessage message)
Uploads the mail message to the specified folder
|
String |
appendMessage(String folder,
MailMessage message,
boolean markAsSent)
Uploads the mail message to the specified folder
|
void |
backup(ExchangeFolderInfoCollection folders,
OutputStream stream,
int options)
Backups the content of the specified folders
|
void |
backup(ExchangeFolderInfoCollection folders,
String fileName,
int options)
Backups the content of the specified folders
|
void |
backupInternal(ExchangeFolderInfoCollection folders,
com.aspose.ms.System.IO.Stream stream,
int options) |
String |
createContact(Contact contact)
Creates a contact item in the Exchange store.
|
String |
createContact(MapiContact contact)
Deprecated.
|
ExchangeFolderInfo |
createFolder(String parentFolderUri,
String name)
Creates the new folder with the specified name in the specified parent folder.
|
void |
deleteContact(Contact contact)
Deletes the contact.
|
void |
deleteContact(MapiContact contact)
Deletes the contact.
|
void |
deleteContact(String id)
Deletes the contact.
|
void |
deleteFolder(String folderUri)
Deletes the folder
|
void |
deleteMessage(String messageUri)
Deletes the mail message.
|
void |
deleteMessage(String messageUri,
boolean suppressReceipt)
Deletes the mail message.
|
Attachment |
fetchAttachment(String attachmentUri)
Fetches the attachment
|
MapiMessage |
fetchMapiMessage(String messageUri)
Fetches the mapi message with specified uri.
|
MailMessage |
fetchMessage(String messageUri)
Fetches the mail message with specified uri.
|
boolean |
folderExists(String parentFolderUri,
String folderName)
Checks whether the specified folder exists.
|
boolean |
folderExists(String parentFolderUri,
String folderName,
ExchangeFolderInfo[] folder)
Checks whether the specified folder exists.
|
com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate |
getClientCertificate()
Gets or sets the client certificate.
|
Contact[] |
getContacts(String folderUri)
Lists contacts located in the specified folder on server
|
com.aspose.ms.System.Net.CookieContainer |
getCookieContainer()
Gets or sets the cookie container.
|
Charset |
getEncoding()
Gets or sets the encoding.
|
ExchangeFolderInfo |
getFolderInfo(String folderUri)
Gets the folder information.
|
boolean |
getKeepAlive()
Indicates whether to keep alive.
|
Contact[] |
getMailboxes()
Lists mailboxes in the global address list.
|
ExchangeMailboxInfo |
getMailboxInfo()
Gets the mailbox information.
|
ExchangeMailboxInfo |
getMailboxInfo(String mailbox)
Gets the mailbox information
|
long |
getMailboxSize()
Get the size of the maibox
|
long |
getMailboxSize(String mailbox)
Get the size of the maibox
|
boolean |
getPreAuthenticate()
Indicates whether to do pre-authentication.
|
boolean |
getSendChunked()
Gets or sets a value indicating whether [send chunked].
|
String |
getVersionInfo()
Returns exchange server version info
|
MapiContact[] |
listContacts(String folderUri)
Lists contacts located in the specified folder on server
|
MapiContactCollection |
listMailboxes()
Lists mailboxes in the global address list.
|
ExchangeMessageInfoCollection |
listMessages(String folder)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessages(String folder,
boolean recursive)
List the messages in the specified folder
|
ExchangeMessageInfoCollection |
listMessages(String folder,
int maxNumberOfMessages)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessages(String folder,
MailQuery query,
boolean recursive)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessages(String folder,
String query)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessages(String folder,
String messageClass,
boolean recursive)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessagesById(String folder,
String messageId)
Lists the messages by id.
|
ExchangeMessageInfoCollection |
listMessagesByMaxNumberOfMessages(String folder,
int maxNumberOfMessages)
Lists the messages.
|
ExchangeMessageInfoCollection |
listMessagesByOption(String folder,
int options)
Lists the mail message in the specified folder.
|
ExchangeMessageInfoCollection |
listMessagesByOption(String folder,
int maxNumberOfMessages,
int options)
List the messages in the specified folder
|
ExchangeFolderInfoCollection |
listPublicFolders()
Gets collection of public folders from root public folder
|
ExchangeFolderInfoCollection |
listSubFolders(ExchangeFolderInfo parentFolder)
Gets collection of child public folders from parent
|
ExchangeFolderInfoCollection |
listSubFolders(String parentFolderUri)
Gets collection of child folders from parent
|
void |
moveItems(String destinationFolderUri,
boolean overwrite,
String... itemsUriArray)
Moves items.
|
void |
moveItems(String destinationFolderUri,
String... itemsUriArray)
Moves items.
|
void |
moveMessage(ExchangeMessageInfo msgInfo,
String destinationFolderUri)
Moves the message.
|
void |
moveMessage(ExchangeMessageInfo msgInfo,
String destinationFolderUri,
boolean overwrite)
Moves the message.
|
void |
moveMessage(String destinationFolderUri,
boolean overwrite,
String messageUri)
Moves the message.
|
void |
moveMessage(String destinationFolderUri,
String messageUri)
Moves the message.
|
MapiContactCollection |
resolveContact(String unresolvedEntry)
Deprecated.
|
Contact[] |
resolveContacts(String unresolvedEntry)
Resolves ambiguous mailbox display names.
|
void |
restore(InputStream stream,
ExchangeFolderInfoCollection folders,
int options)
Restores the specified exchange folders from the given personal storage.
|
void |
restore(InputStream stream,
int options)
Restores exchange folders from the given personal storage.
|
void |
restore(PersonalStorage pst,
ExchangeFolderInfoCollection folders,
int options)
Restores the specified exchange folders from the given personal storage.
|
void |
restore(PersonalStorage pst,
int options)
Restores exchange folders from the given personal storage.
|
void |
restore(String fileName,
ExchangeFolderInfoCollection folders,
int options)
Restores the specified exchange folders from the specified personal storage file.
|
void |
restore(String fileName,
int options)
Restores exchange folders from the specified personal storage file.
|
void |
restoreInternal(com.aspose.ms.System.IO.Stream stream,
ExchangeFolderInfoCollection folders,
int options) |
void |
restoreInternal(com.aspose.ms.System.IO.Stream stream,
int options) |
void |
saveMessage(String messageUri,
OutputStream stream)
Saves the message.
|
void |
saveMessage(String messageUri,
String path)
Saves mail message specified by the uri to local file system.
|
void |
saveMessageInternal(String messageUri,
com.aspose.ms.System.IO.Stream stream) |
void |
send(MailMessage message)
Sends the mail message.
|
void |
setClientCertificate(com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate value)
Gets or sets the client certificate.
|
void |
setCookieContainer(com.aspose.ms.System.Net.CookieContainer value)
Gets or sets the cookie container.
|
void |
setEncoding(Charset value)
Gets or sets the encoding.
|
void |
setKeepAlive(boolean value)
Indicates whether to keep alive.
|
void |
setPreAuthenticate(boolean value)
Indicates whether to do pre-authentication.
|
void |
setReadFlag(String messageUri)
Marks the specifeid message as read.
|
void |
setReadFlag(String messageUri,
boolean suppressReceipt)
Marks the specifeid message as read.
|
void |
setSendChunked(boolean value)
Gets or sets a value indicating whether [send chunked].
|
dispose, dispose, getCredentials, getLogFileName, getMailboxUri, getProxy, getTimeout, getUseDateInLogFileName, resetLogSettings, setCredentials, setLogFileName, setMailboxUri, setProxy, setTimeout, setUseDateInLogFileName
public ExchangeClient(String mailboxUri, String username, String password)
Initialize a new instance of the class ExchangeClient
mailboxUri
- The url of the mailboxusername
- The username of the mailboxpassword
- The password of the mailboxpublic ExchangeClient(String mailboxUri, String username, String password, String domain)
Initialize a new instance of the class ExchangeClient
mailboxUri
- The url of the mailboxusername
- The username of the mailboxpassword
- The password of the mailboxdomain
- The domain of the userpublic ExchangeClient(String mailboxUri, com.aspose.ms.System.Net.ICredentials credentials)
Initialize a new instance of the class ExchangeClient
mailboxUri
- The url of the mailboxcredentials
- The credentials used to log inpublic final com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate getClientCertificate()
Gets or sets the client certificate.
public final void setClientCertificate(com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate value)
Gets or sets the client certificate.
public final boolean getKeepAlive()
Indicates whether to keep alive.
public final void setKeepAlive(boolean value)
Indicates whether to keep alive.
public final boolean getPreAuthenticate()
Indicates whether to do pre-authentication.
public final void setPreAuthenticate(boolean value)
Indicates whether to do pre-authentication.
public final Charset getEncoding()
Gets or sets the encoding.
public final void setEncoding(Charset value)
Gets or sets the encoding.
public final ExchangeMailboxInfo getMailboxInfo()
Gets the mailbox information.
public final com.aspose.ms.System.Net.CookieContainer getCookieContainer()
Gets or sets the cookie container.
Value: The cookie container.public final void setCookieContainer(com.aspose.ms.System.Net.CookieContainer value)
Gets or sets the cookie container.
Value: The cookie container.public final boolean getSendChunked()
Gets or sets a value indicating whether [send chunked].
Value:true
if [send chunked]; otherwise, false
.public final void setSendChunked(boolean value)
Gets or sets a value indicating whether [send chunked].
Value:true
if [send chunked]; otherwise, false
.public final void moveMessage(ExchangeMessageInfo msgInfo, String destinationFolderUri)
Moves the message.
msgInfo
- Represents the E-Mail message info fetched from the Exchange Store.destinationFolderUri
- An URI of a destination folder.public final void moveMessage(ExchangeMessageInfo msgInfo, String destinationFolderUri, boolean overwrite)
Moves the message.
msgInfo
- Represents the E-Mail message info fetched from the Exchange Store.destinationFolderUri
- An URI of a destination folder.overwrite
- Specifies whether the server should overwrite a existing message while processing a MOVE operation.public final void moveMessage(String destinationFolderUri, String messageUri)
Moves the message.
destinationFolderUri
- An URI of a destination folder.messageUri
- Represents the uri of E-Mail message.public final void moveMessage(String destinationFolderUri, boolean overwrite, String messageUri)
Moves the message.
destinationFolderUri
- An URI of a destination folder.overwrite
- Specifies whether the server should overwrite a existing message while processing a MOVE operation.messageUri
- Represents the uri of E-Mail message.public final void moveItems(String destinationFolderUri, String... itemsUriArray)
Moves items.
destinationFolderUri
- The new destination for items.itemsUriArray
- Items uri arrraypublic final void moveItems(String destinationFolderUri, boolean overwrite, String... itemsUriArray)
Moves items.
destinationFolderUri
- The new destination for items.overwrite
- Specifies whether the server should overwrite a existing message while processing a MOVE operation.itemsUriArray
- Items uri arrraypublic final long getMailboxSize()
Get the size of the maibox
public final long getMailboxSize(String mailbox)
Get the size of the maibox
mailbox
- A mailbox. Note: if it is set to null
or empty
the default mailbox will be usedpublic final String getVersionInfo()
Returns exchange server version info
public final ExchangeMailboxInfo getMailboxInfo(String mailbox)
Gets the mailbox information
mailbox
- A mailbox to read from. Note: if mailbox is set to null
or empty
the default mailbox will be usedExchangeMailboxInfo
that represents mailbox informationpublic final ExchangeMessageInfoCollection listMessages(String folder, String messageClass, boolean recursive)
Lists the messages.
folder
- The folder.messageClass
- The message class.recursive
- if set to true
[recursive].public final ExchangeMessageInfoCollection listMessages(String folder, boolean recursive)
List the messages in the specified folder
folder
- The folder Urirecursive
- Indicates whether recursive listing or not.public final ExchangeMessageInfoCollection listMessages(String folder, String query)
Lists the messages.
folder
- The folder.query
- The query.public final ExchangeMessageInfoCollection listMessages(String folder, MailQuery query, boolean recursive)
Lists the messages.
folder
- The Uri of folder that contains messages.query
- The MailQuery
that represents search criteria.recursive
- Indicates whether recursive listing or not.public final ExchangeMessageInfoCollection listMessagesById(String folder, String messageId)
Lists the messages by id.
folder
- The folder.messageId
- The message id.public final ExchangeMessageInfoCollection listMessagesByOption(String folder, int options)
Lists the mail message in the specified folder.
folder
- The folder urloptions
- Specifies the settings of listingExchangeMessageInfoCollection
collection.public final void saveMessage(String messageUri, String path)
Saves mail message specified by the uri to local file system. The mail message file is RFC 822 compliant format (EML).
messageUri
- The Uri of the mail messagepath
- The target path to save the message
MailMessage
.public final void saveMessage(String messageUri, OutputStream stream)
Saves the message.
messageUri
- The message URI.stream
- The stream.public void saveMessageInternal(String messageUri, com.aspose.ms.System.IO.Stream stream)
public final void send(MailMessage message)
Sends the mail message.
message
- The mail message to be sent.public final void setReadFlag(String messageUri)
Marks the specifeid message as read.
messageUri
- A message uri.AsposeArgumentException
- messageUri
is null
or empty
.public final void setReadFlag(String messageUri, boolean suppressReceipt)
Marks the specifeid message as read.
messageUri
- A message uri.suppressReceipt
- A value indicating whether the sending a read receipt should be suppressed.AsposeArgumentException
- messageUri
is null
or empty
.public final ExchangeFolderInfoCollection listPublicFolders()
Gets collection of public folders from root public folder
ExchangeFolderInfoCollection
that contains subfolders from the root public folderpublic final ExchangeFolderInfoCollection listSubFolders(String parentFolderUri)
Gets collection of child folders from parent
parentFolderUri
- The uri of the parent folderExchangeFolderInfoCollection
that contains subfolders from the parent folderAsposeArgumentException
- parentFolderUri
is null
or empty
public final MailMessage fetchMessage(String messageUri)
Fetches the mail message with specified uri.
messageUri
- The message uri.public final MapiMessage fetchMapiMessage(String messageUri)
Fetches the mapi message with specified uri.
messageUri
- The message uri.MapiMessage
object contains the message.AsposeArgumentNullException
- messageUri
is nullAsposeArgumentException
- messageUri
is empty stringpublic final void deleteMessage(String messageUri)
Deletes the mail message.
messageUri
- The message uri.AsposeArgumentException
- messageUri
is empty
.AsposeArgumentNullException
- messageUri
is null
.public final void deleteMessage(String messageUri, boolean suppressReceipt)
Deletes the mail message.
messageUri
- The message uri.suppressReceipt
- A value indicating whether the sending a non-read report should be suppressed.AsposeArgumentException
- messageUri
is empty
.AsposeArgumentNullException
- messageUri
is null
.public final String appendMessage(String folder, MailMessage message)
Uploads the mail message to the specified folder
folder
- A folder to which message is uploadedmessage
- A message to uploadAsposeArgumentException
- A folder is not specifiedAsposeArgumentNullException
- message
is null
public final String appendMessage(String folder, MailMessage message, boolean markAsSent)
Uploads the mail message to the specified folder
folder
- An uri of folder to which message is uploadedmessage
- A message to uploadmarkAsSent
- A value indicating whether the message should be appended as a sent message or a draft.AsposeArgumentException
- A folder is not specifiedAsposeArgumentNullException
- message
is null
public ExchangeMessageInfoCollection listMessagesByOption(String folder, int maxNumberOfMessages, int options)
List the messages in the specified folder
folder
- The folder UrimaxNumberOfMessages
- Maximum number of messagesoptions
- Specifies the settings of listingpublic final Attachment fetchAttachment(String attachmentUri)
Fetches the attachment
attachmentUri
- The attachment uri.
(Attachment uri can be retrieved using ListMessages(folder, ExchangeListMessagesOptions.FetchAttachmentInformation) method)Attachment
that represents fetched attachmentAsposeArgumentException
- attachmentUri
is null or emptypublic final void backup(ExchangeFolderInfoCollection folders, String fileName, int options)
Backups the content of the specified folders
folders
- A folders to backupfileName
- A path to the presonal storage fileoptions
- A backup optionsAsposeArgumentException
- A fileName
is null
or empty
AsposeArgumentNullException
- folders
is null
public final void backup(ExchangeFolderInfoCollection folders, OutputStream stream, int options)
Backups the content of the specified folders
folders
- A folders to backupstream
- A stream to write intooptions
- A backup optionscom.aspose.ms.System.NotSupportedException
- The given stream does not support writtingAsposeArgumentNullException
- folders
or stream
is null
public void backupInternal(ExchangeFolderInfoCollection folders, com.aspose.ms.System.IO.Stream stream, int options)
public final ExchangeFolderInfo getFolderInfo(String folderUri)
Gets the folder information.
folderUri
- A folder uri.ExchangeFolderInfo
that represents the folder information.AsposeArgumentException
- folderUri
is null
or empty
.ExchangeException
- Server responded an error message.public final boolean folderExists(String parentFolderUri, String folderName, ExchangeFolderInfo[] folder)
Checks whether the specified folder exists.
parentFolderUri
- An uri of parent folder.folderName
- A folder name.folder
- A ExchangeFolderInfo
that represents the found folder information, if folder exists.true
if the specified folder exists in the specified parent folder; otherwise, false
.AsposeArgumentException
- parentFolderUri
or folderName
is null
or empty
public ExchangeFolderInfo createFolder(String parentFolderUri, String name)
Creates the new folder with the specified name in the specified parent folder.
parentFolderUri
- An uri of parent folder.name
- A name of folder to be created.AsposeArgumentException
- parentFolderUri
or name
is null
or empty
.public final void deleteFolder(String folderUri)
Deletes the folder
folderUri
- The folder UriAsposeArgumentException
- folderUri
is null
or empty
public final void restore(String fileName, int options)
Restores exchange folders from the specified personal storage file.
fileName
- A path to personal storage file.options
- Restore options.AsposeArgumentException
- fileName
is not specified.public final void restore(InputStream stream, int options)
Restores exchange folders from the given personal storage.
stream
- A stream containing personal storage.options
- Restore options.com.aspose.ms.System.NotSupportedException
- The stream
does not support reading.AsposeArgumentNullException
- stream
is null
.public void restoreInternal(com.aspose.ms.System.IO.Stream stream, int options)
public final void restore(PersonalStorage pst, int options)
Restores exchange folders from the given personal storage.
pst
- A personal storage containing the backuped imap folders.options
- Restore options.AsposeArgumentNullException
- pst
is null
.public final void restore(String fileName, ExchangeFolderInfoCollection folders, int options)
Restores the specified exchange folders from the specified personal storage file.
fileName
- A path to personal storage file.folders
- A folders to be restored.options
- Restore options.AsposeArgumentException
- fileName
is not specified.AsposeArgumentNullException
- folders
is null
.public final void restore(InputStream stream, ExchangeFolderInfoCollection folders, int options)
Restores the specified exchange folders from the given personal storage.
stream
- A stream containing personal storage.folders
- A folders to be restored.options
- Restore options.com.aspose.ms.System.NotSupportedException
- The stream
does not support reading.AsposeArgumentNullException
- stream
or folders
is null
.public void restoreInternal(com.aspose.ms.System.IO.Stream stream, ExchangeFolderInfoCollection folders, int options)
public final void restore(PersonalStorage pst, ExchangeFolderInfoCollection folders, int options)
Restores the specified exchange folders from the given personal storage.
pst
- A personal storage containing the backuped exchange folders.folders
- A folders to be restored.options
- Restore options.AsposeArgumentNullException
- pst
or folders
is null
.@Deprecated public final String createContact(MapiContact contact)
Creates a contact item in the Exchange store.
contact
- Contact itempublic final String createContact(Contact contact)
Creates a contact item in the Exchange store.
contact
- Contact itempublic final void deleteContact(Contact contact)
Deletes the contact.
contact
- Contactpublic final void deleteContact(MapiContact contact)
Deletes the contact.
contact
- Contactpublic final void deleteContact(String id)
Deletes the contact.
id
- The contact identifier.public final Contact[] getContacts(String folderUri)
Lists contacts located in the specified folder on server
folderUri
- The URI of folderContact
that represents contact informationpublic final MapiContact[] listContacts(String folderUri)
Lists contacts located in the specified folder on server
folderUri
- The URI of folderMapiContact
that represents contact information@Deprecated public final MapiContactCollection resolveContact(String unresolvedEntry)
Resolves ambiguous mailbox display names. Note: the maximum count of returned contacts is 100. This is a restriction of used exchange command.
unresolvedEntry
- A name of contact to resolve.MapiContactCollection
that represents contacts information.AsposeArgumentException
- unresolvedEntry
is null
or empty
.public final Contact[] resolveContacts(String unresolvedEntry)
Resolves ambiguous mailbox display names. Note: the maximum count of returned contacts is 100. This is a restriction of used exchange command.
unresolvedEntry
- A name of contact to resolve.Contact
objects.public final MapiContactCollection listMailboxes()
Lists mailboxes in the global address list.
MapiContactCollection
that represents contact information.public final Contact[] getMailboxes()
Lists mailboxes in the global address list.
Contact
objects.public final ExchangeFolderInfoCollection listSubFolders(ExchangeFolderInfo parentFolder)
Gets collection of child public folders from parent
parentFolder
- The parent ExchangeFolderInfo
ExchangeFolderInfoCollection
that contains subfolders from the parent folderpublic final ExchangeMessageInfoCollection listMessages(String folder)
Lists the messages.
folder
- The folder.ExchangeMessageInfoCollection
public final ExchangeMessageInfoCollection listMessages(String folder, int maxNumberOfMessages)
Lists the messages.
folder
- The folder.maxNumberOfMessages
- Maximum number of messagesExchangeMessageInfoCollection
public final ExchangeMessageInfoCollection listMessagesByMaxNumberOfMessages(String folder, int maxNumberOfMessages)
Lists the messages.
folder
- The folder.maxNumberOfMessages
- Maximum number of messagesExchangeMessageInfoCollection
public final boolean folderExists(String parentFolderUri, String folderName)
Checks whether the specified folder exists.
parentFolderUri
- An uri of parent folder.folderName
- A folder name.true
if the specified folder exists in the specified parent folder; otherwise, false
.AsposeArgumentException
- parentFolderUri
or folderName
is null
or empty