Re: Re: clueless newbie -- how to open mbox?
Chris Burdess <[email protected]> Thu, 3 May 2007 13:59:33 +0100
| Newsgroups | gmane.comp.java.classpath.extensions.javamail |
|---|---|
| Message-ID | <[email protected]> |
Matej Cepl wrote:
> When (following http://tinyurl.com/ysqmfx ) I tried other
> variant, I got back to the square one:
>
> [matej@hubmaier kmail2tbfolders]$ cat -b test.java
> 1 import java.util.*;
> 2 import javax.mail.*;
>
> 3 public class test {
> 4 public static void main(String[] args) throws
> MessagingException {
> 5 String urlStr
> = ``/home/matej/.eclipse/workspace\
> /kmail2tbfolders/examples/``';
> 6 Session session = Session.getInstance(new
> Properties());
> 7 URLName storeURL = new
> URLName(``'mbox://``'+urlStr);
> 8 Store store
> = session.getStore(storeURL);
> 9 Folder test
> = store.getDefaultFolder();
> 10 test = test.getFolder(``'test``');
> 11 test.open(Folder.READ_WRITE);
> 12 try { 13
> test.open(Folder.READ_WRITE);
> 14 } catch (MessagingException ex) {
> 15 test.open(Folder.READ_ONLY);
> 16 }
> 17 }
> 18 }
You will need to put store.connect() and store.close(), just like
with any other JavaMail provider.