• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to copy messages from Inbox to some custom folder in outlook.  RSS feed

 
Mohamed Shafi Shamsuddin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to copy messages from Inbox to some custom (say 'DestinationFolderName') folder in outlook.

This is the code snippet:

Folder inbox = store.getFolder("Inbox");
inbox.copyMessages(msgs, <DestinationFolderName>);

I created destination folder manually. I have the complete code but in the above line while trying to copy the messages from Inbox to the <DestinationFolderName> getting the below error though the destination folder exists. I'm using pop3 protocol and javax.mail.*

javax.mail.FolderNotFoundException: <DestinationFolderName> does not exist
at javax.mail.Folder.copyMessages(Folder.java:1132)
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Shafi Shamsuddin wrote:I'm using pop3 protocol...


... and POP3 doesn't have the concept of "folders". If you want to work with folders then you can't use POP3. Try IMAP instead.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
Mohamed Shafi Shamsuddin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Paul. It worked when I used IMAP protocol.
 
Mohamed Shafi Shamsuddin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul Clapham,
Now I can COPY messages from Inbox to any custom folder using IMAP.
Do you know whether I can MOVE messages from Inbox to any custom folder??? (Message should get deleted from Inbox folder).

 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried deleting the originals after copying them?
 
Mohamed Shafi Shamsuddin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is one method available to delete but that did not work for me.

inbox.expunge(); // This did not work and messages was not deleted.

abstract Message[] expunge() (Expunge (permanently remove) messages marked DELETED.)

Thanks for your help Rob.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mark the message as deleted first?
 
Mohamed Shafi Shamsuddin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Rob. I set the flag and the messages got deleted now.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!