How to move message from one folder to another?

Asif Sajjad

Here is the code I am using to move the messages to another folder. In findFolder method I search for the folder name and then open the folder to read-write. CurrentFolder is the folder from where the messages are copied to the destination folder.

public void saveMessages(Message[] mArray, String folderName) throws Exception{
      Folder f = findFolder(folderName);
      currentFolder.copyMessages(mArray, f);

      // Now the delete the messages from Current Folder
      for ( int i = 0; i < mArray.length; i++){
          mArray[i].setFlag(Flags.Flag.DELETED, true);
      }
      currentFolder.expunge();
   }

[Keep in mind this is for IMAP only. POP doesn't support folders.]
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact