Working with Folders on IMAP Server
Getting Folders Information
Getting information about folders from an IMAP server is very easy with Aspose.Email. The listFolders() method of ImapClient returns an object of the ImapFolderInfoCollection that contains information about all the server folders. Iterate through this collection and get information about individual folders in a loop. The method is overloaded. You can pass a folder name as a parameter to get a list of subfolders.
Adding a New Message in a Folder
Add Multiple Messages with MultiConnection Support
You can add multiple messages by using the AppendMessages method provided by the ImapClient classes. The AppendMessages method accepts a list of MailMessage and adds it to the current folder if the folder is not provided as a parameter. ImapClient also supports MultiConnection mode for heavy loaded operations. The following code snippet shows you how to add multiple messages by using the MultiConnection mode.
Move Messages to Another Mailbox Folder
Aspose.Email API provides the capability to move a message from one folder of a mailbox to another. The ImapClient’s moveMessage method and it’s overloads provides the facility to move a message using its unique id or sequence number to another folder.
Copy Message to Another Mailbox Folder
Aspose.Email API provides the capability to copy message from one mailbox folder to another. It allows copying a single as well as multiple messages using the copyMessage and copyMessages methods. The copyMessages method provides the capability to copy multiple messages from source folder of a mailbox to the destination mailbox folder. The following code sample illustrates this by copying two messages.
Working with Special-Use Mailbox Folders
Some IMAP message stores include special-use mailboxes, such as those used to hold draft messages or sent messages. Many mail clients allow users to specify where the draft or sent messages should be put, but configuring them requires that the user know which mailboxes the server has set aside for these purposes. Aspose.Email can identify these special-use mailboxes by using the ImapMailboxInfo class to make it easier to work with them. The following code sample demonstrates how to access these special-use mailboxes by using the ImapMailboxInfo class.