com.aspose.email

Interfaces

Classes

Enums

Exceptions

com.aspose.email

Class ExchangeClient

  • All Implemented Interfaces:
    IExchangeClientBase, com.aspose.ms.System.IDisposable


    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 Detail

      • ExchangeClient

        public ExchangeClient(String mailboxUri,
                      String username,
                      String password)

        Initialize a new instance of the class ExchangeClient

        Parameters:
        mailboxUri - The url of the mailbox
        username - The username of the mailbox
        password - The password of the mailbox
      • ExchangeClient

        public ExchangeClient(String mailboxUri,
                      String username,
                      String password,
                      String domain)

        Initialize a new instance of the class ExchangeClient

        Parameters:
        mailboxUri - The url of the mailbox
        username - The username of the mailbox
        password - The password of the mailbox
        domain - The domain of the user
      • ExchangeClient

        public ExchangeClient(String mailboxUri,
                      com.aspose.ms.System.Net.ICredentials credentials)

        Initialize a new instance of the class ExchangeClient

        Parameters:
        mailboxUri - The url of the mailbox
        credentials - The credentials used to log in
    • Method Detail

      • getClientCertificate

        public final com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate getClientCertificate()

        Gets or sets the client certificate.

      • setClientCertificate

        public final void setClientCertificate(com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate value)

        Gets or sets the client certificate.

      • getKeepAlive

        public final boolean getKeepAlive()

        Indicates whether to keep alive.

      • setKeepAlive

        public final void setKeepAlive(boolean value)

        Indicates whether to keep alive.

      • getPreAuthenticate

        public final boolean getPreAuthenticate()

        Indicates whether to do pre-authentication.

      • setPreAuthenticate

        public final void setPreAuthenticate(boolean value)

        Indicates whether to do pre-authentication.

      • getEncoding

        public final Charset getEncoding()

        Gets or sets the encoding.

      • setEncoding

        public final void setEncoding(Charset value)

        Gets or sets the encoding.

      • getMailboxInfo

        public final ExchangeMailboxInfo getMailboxInfo()

        Gets the mailbox information.

      • getCookieContainer

        public final com.aspose.ms.System.Net.CookieContainer getCookieContainer()

        Gets or sets the cookie container.

        Value: The cookie container.
      • setCookieContainer

        public final void setCookieContainer(com.aspose.ms.System.Net.CookieContainer value)

        Gets or sets the cookie container.

        Value: The cookie container.
      • getSendChunked

        public final boolean getSendChunked()

        Gets or sets a value indicating whether [send chunked].

        Value: true if [send chunked]; otherwise, false.
      • setSendChunked

        public final void setSendChunked(boolean value)

        Gets or sets a value indicating whether [send chunked].

        Value: true if [send chunked]; otherwise, false.
      • moveMessage

        public final void moveMessage(ExchangeMessageInfo msgInfo,
                       String destinationFolderUri)

        Moves the message.

        Parameters:
        msgInfo - Represents the E-Mail message info fetched from the Exchange Store.
        destinationFolderUri - An URI of a destination folder.
      • moveMessage

        public final void moveMessage(ExchangeMessageInfo msgInfo,
                       String destinationFolderUri,
                       boolean overwrite)

        Moves the message.

        Parameters:
        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.
      • moveMessage

        public final void moveMessage(String destinationFolderUri,
                       String messageUri)

        Moves the message.

        Parameters:
        destinationFolderUri - An URI of a destination folder.
        messageUri - Represents the uri of E-Mail message.
      • moveMessage

        public final void moveMessage(String destinationFolderUri,
                       boolean overwrite,
                       String messageUri)

        Moves the message.

        Parameters:
        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.
      • moveItems

        public final void moveItems(String destinationFolderUri,
                     String... itemsUriArray)

        Moves items.

        Parameters:
        destinationFolderUri - The new destination for items.
        itemsUriArray - Items uri arrray
      • moveItems

        public final void moveItems(String destinationFolderUri,
                     boolean overwrite,
                     String... itemsUriArray)

        Moves items.

        Parameters:
        destinationFolderUri - The new destination for items.
        overwrite - Specifies whether the server should overwrite a existing message while processing a MOVE operation.
        itemsUriArray - Items uri arrray
      • getMailboxSize

        public final long getMailboxSize()

        Get the size of the maibox

        Returns:
        The size of the mailbox
      • getMailboxSize

        public final long getMailboxSize(String mailbox)

        Get the size of the maibox

        Parameters:
        mailbox - A mailbox. Note: if it is set to null or empty the default mailbox will be used
        Returns:
        The size of the mailbox
      • getVersionInfo

        public final String getVersionInfo()

        Returns exchange server version info

        Returns:
        Returns exchange server version info
      • getMailboxInfo

        public final ExchangeMailboxInfo getMailboxInfo(String mailbox)

        Gets the mailbox information

        Parameters:
        mailbox - A mailbox to read from. Note: if mailbox is set to null or empty the default mailbox will be used
        Returns:
        ExchangeMailboxInfo that represents mailbox information
      • listMessages

        public final ExchangeMessageInfoCollection listMessages(String folder,
                                                 String messageClass,
                                                 boolean recursive)

        Lists the messages.

        Parameters:
        folder - The folder.
        messageClass - The message class.
        recursive - if set to true [recursive].
        Returns:
      • listMessages

        public final ExchangeMessageInfoCollection listMessages(String folder,
                                                 boolean recursive)

        List the messages in the specified folder

        Parameters:
        folder - The folder Uri
        recursive - Indicates whether recursive listing or not.
        Returns:
        A collection of message info
      • listMessages

        public final ExchangeMessageInfoCollection listMessages(String folder,
                                                 MailQuery query,
                                                 boolean recursive)

        Lists the messages.

        Parameters:
        folder - The Uri of folder that contains messages.
        query - The MailQuery that represents search criteria.
        recursive - Indicates whether recursive listing or not.
        Returns:
        The message info collection.
      • listMessagesById

        public final ExchangeMessageInfoCollection listMessagesById(String folder,
                                                     String messageId)

        Lists the messages by id.

        Parameters:
        folder - The folder.
        messageId - The message id.
        Returns:
      • saveMessage

        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).

        Parameters:
        messageUri - The Uri of the mail message
        path - The target path to save the message


        if you want to parse the mail message files, use MailMessage.

      • saveMessage

        public final void saveMessage(String messageUri,
                       OutputStream stream)

        Saves the message.

        Parameters:
        messageUri - The message URI.
        stream - The stream.
      • saveMessageInternal

        public void saveMessageInternal(String messageUri,
                               com.aspose.ms.System.IO.Stream stream)
      • send

        public final void send(MailMessage message)

        Sends the mail message.

        Parameters:
        message - The mail message to be sent.
      • setReadFlag

        public final void setReadFlag(String messageUri)

        Marks the specifeid message as read.

        Parameters:
        messageUri - A message uri.
        Throws:
        AsposeArgumentException - messageUri is null or empty.
      • setReadFlag

        public final void setReadFlag(String messageUri,
                       boolean suppressReceipt)

        Marks the specifeid message as read.

        Parameters:
        messageUri - A message uri.
        suppressReceipt - A value indicating whether the sending a read receipt should be suppressed.
        Throws:
        AsposeArgumentException - messageUri is null or empty.
      • fetchMessage

        public final MailMessage fetchMessage(String messageUri)

        Fetches the mail message with specified uri.

        Parameters:
        messageUri - The message uri.
        Returns:
        A MailMessage object contains the message.
      • deleteMessage

        public final void deleteMessage(String messageUri,
                         boolean suppressReceipt)

        Deletes the mail message.

        Parameters:
        messageUri - The message uri.
        suppressReceipt - A value indicating whether the sending a non-read report should be suppressed.
        Throws:
        AsposeArgumentException - messageUri is empty.
        AsposeArgumentNullException - messageUri is null.
      • appendMessage

        public final String appendMessage(String folder,
                           MailMessage message)

        Uploads the mail message to the specified folder

        Parameters:
        folder - A folder to which message is uploaded
        message - A message to upload
        Returns:
        An uri of created message
        Throws:
        AsposeArgumentException - A folder is not specified
        AsposeArgumentNullException - message is null
      • appendMessage

        public final String appendMessage(String folder,
                           MailMessage message,
                           boolean markAsSent)

        Uploads the mail message to the specified folder

        Parameters:
        folder - An uri of folder to which message is uploaded
        message - A message to upload
        markAsSent - A value indicating whether the message should be appended as a sent message or a draft.
        Returns:
        An uri of created message
        Throws:
        AsposeArgumentException - A folder is not specified
        AsposeArgumentNullException - message is null
      • listMessagesByOption

        public ExchangeMessageInfoCollection listMessagesByOption(String folder,
                                                         int maxNumberOfMessages,
                                                         int options)

        List the messages in the specified folder

        Parameters:
        folder - The folder Uri
        maxNumberOfMessages - Maximum number of messages
        options - Specifies the settings of listing
        Returns:
        A collection of message info
      • fetchAttachment

        public final Attachment fetchAttachment(String attachmentUri)

        Fetches the attachment

        Parameters:
        attachmentUri - The attachment uri. (Attachment uri can be retrieved using ListMessages(folder, ExchangeListMessagesOptions.FetchAttachmentInformation) method)
        Returns:
        Attachment that represents fetched attachment
        Throws:
        AsposeArgumentException - attachmentUri is null or empty
      • backup

        public final void backup(ExchangeFolderInfoCollection folders,
                  OutputStream stream,
                  int options)

        Backups the content of the specified folders

        Parameters:
        folders - A folders to backup
        stream - A stream to write into
        options - A backup options
        Throws:
        com.aspose.ms.System.NotSupportedException - The given stream does not support writting
        AsposeArgumentNullException - folders or stream is null
      • folderExists

        public final boolean folderExists(String parentFolderUri,
                           String folderName,
                           ExchangeFolderInfo[] folder)

        Checks whether the specified folder exists.

        Parameters:
        parentFolderUri - An uri of parent folder.
        folderName - A folder name.
        folder - A ExchangeFolderInfo that represents the found folder information, if folder exists.
        Returns:
        true if the specified folder exists in the specified parent folder; otherwise, false.
        Throws:
        AsposeArgumentException - parentFolderUri or folderName is null or empty
      • createFolder

        public ExchangeFolderInfo createFolder(String parentFolderUri,
                                      String name)

        Creates the new folder with the specified name in the specified parent folder.

        Parameters:
        parentFolderUri - An uri of parent folder.
        name - A name of folder to be created.
        Throws:
        AsposeArgumentException - parentFolderUri or name is null or empty.
      • deleteFolder

        public final void deleteFolder(String folderUri)

        Deletes the folder

        Parameters:
        folderUri - The folder Uri
        Throws:
        AsposeArgumentException - folderUri is null or empty
      • restore

        public final void restore(String fileName,
                   int options)

        Restores exchange folders from the specified personal storage file.

        Parameters:
        fileName - A path to personal storage file.
        options - Restore options.
        Throws:
        AsposeArgumentException - fileName is not specified.
      • restore

        public final void restore(InputStream stream,
                   int options)

        Restores exchange folders from the given personal storage.

        Parameters:
        stream - A stream containing personal storage.
        options - Restore options.
        Throws:
        com.aspose.ms.System.NotSupportedException - The stream does not support reading.
        AsposeArgumentNullException - stream is null.
      • restoreInternal

        public void restoreInternal(com.aspose.ms.System.IO.Stream stream,
                           int options)
      • restore

        public final void restore(PersonalStorage pst,
                   int options)

        Restores exchange folders from the given personal storage.

        Parameters:
        pst - A personal storage containing the backuped imap folders.
        options - Restore options.
        Throws:
        AsposeArgumentNullException - pst is null.
      • restore

        public final void restore(InputStream stream,
                   ExchangeFolderInfoCollection folders,
                   int options)

        Restores the specified exchange folders from the given personal storage.

        Parameters:
        stream - A stream containing personal storage.
        folders - A folders to be restored.
        options - Restore options.
        Throws:
        com.aspose.ms.System.NotSupportedException - The stream does not support reading.
        AsposeArgumentNullException - stream or folders is null.
      • restoreInternal

        public void restoreInternal(com.aspose.ms.System.IO.Stream stream,
                           ExchangeFolderInfoCollection folders,
                           int options)
      • restore

        public final void restore(PersonalStorage pst,
                   ExchangeFolderInfoCollection folders,
                   int options)

        Restores the specified exchange folders from the given personal storage.

        Parameters:
        pst - A personal storage containing the backuped exchange folders.
        folders - A folders to be restored.
        options - Restore options.
        Throws:
        AsposeArgumentNullException - pst or folders is null.
      • createContact

        @Deprecated
        public final String createContact(MapiContact contact)
        Deprecated. 

        Creates a contact item in the Exchange store.

        Parameters:
        contact - Contact item
        Returns:
        The contact Uri
      • createContact

        public final String createContact(Contact contact)

        Creates a contact item in the Exchange store.

        Parameters:
        contact - Contact item
        Returns:
        The contact Uri
      • deleteContact

        public final void deleteContact(Contact contact)

        Deletes the contact.

        Parameters:
        contact - Contact
      • deleteContact

        public final void deleteContact(MapiContact contact)

        Deletes the contact.

        Parameters:
        contact - Contact
      • deleteContact

        public final void deleteContact(String id)

        Deletes the contact.

        Parameters:
        id - The contact identifier.
      • getContacts

        public final Contact[] getContacts(String folderUri)

        Lists contacts located in the specified folder on server

        Parameters:
        folderUri - The URI of folder
        Returns:
        An array of read Contact that represents contact information
      • listContacts

        public final MapiContact[] listContacts(String folderUri)

        Lists contacts located in the specified folder on server

        Parameters:
        folderUri - The URI of folder
        Returns:
        An array of read MapiContact that represents contact information
      • resolveContact

        @Deprecated
        public final MapiContactCollection resolveContact(String unresolvedEntry)
        Deprecated. 

        Resolves ambiguous mailbox display names. Note: the maximum count of returned contacts is 100. This is a restriction of used exchange command.

        Parameters:
        unresolvedEntry - A name of contact to resolve.
        Returns:
        A MapiContactCollection that represents contacts information.
        Throws:
        AsposeArgumentException - unresolvedEntry is null or empty.
      • resolveContacts

        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.

        Parameters:
        unresolvedEntry - A name of contact to resolve.
        Returns:
        An array of Contact objects.
      • getMailboxes

        public final Contact[] getMailboxes()

        Lists mailboxes in the global address list.

        Returns:
        An array of Contact objects.
      • listMessagesByMaxNumberOfMessages

        public final ExchangeMessageInfoCollection listMessagesByMaxNumberOfMessages(String folder,
                                                                      int maxNumberOfMessages)

        Lists the messages.

        Parameters:
        folder - The folder.
        maxNumberOfMessages - Maximum number of messages
        Returns:
        A ExchangeMessageInfoCollection
      • folderExists

        public final boolean folderExists(String parentFolderUri,
                           String folderName)

        Checks whether the specified folder exists.

        Parameters:
        parentFolderUri - An uri of parent folder.
        folderName - A folder name.
        Returns:
        true if the specified folder exists in the specified parent folder; otherwise, false.
        Throws:
        AsposeArgumentException - parentFolderUri or folderName is null or empty

Copyright (c) 2008-2019 Aspose Pty Ltd. All Rights Reserved.