I am working on a webmail client in Java and i saw mstor and i have some questions about it :).
can be mstore used to receive the messages from the pop3 server and store them locally?
I am using JavaMail to get the messages but the rroblem is that for a large email i ma getting OutOfMemory exception. :(
Caould you provide me with an example if mstor can be used to receive messahes from pop3?
Thank you,
akovari
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You should definitely be able to retrieve messages from a POP3 server and store them locally using mstor - that is basically the purpose of mstor! :)
I'm not sure exactly of the OutOfMemory problem you are having, although its possibly a bug in mstor. If you can post me the stack trace when you get the exception then I might be able to track down what the problem is.
Also, you may want to try using small email messages for starters - its possible that if you have large emails (or attachments) that this is causing the problem.
regards,
ben
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get the OutOfMemory message when i use JavaMail (without mstor.). I did not try it with mstor.
Can you please point me to some direction where i could find some examples on how to get the messages from the pop3 server using mstor?
thank you very mutch,
akovari
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are many examples available on the Web (and even included with the JavaMail distribution I believe?!) that will show you how to read messages from a POP3 server and write them to a local store (either mstor or otherwise). You might want to do a quick search to see what you can find.
Nevertheless I will try to make a quick example of how to do this and add it to the "Usage" section of the documentation here:
For my application, I need to be able to quickly query messages based on header values, for example Message-ID and In-Reply-To values. I might have a large amount of messages (let's say, over 1000), and they might be located in over a dozen folders, can mstor efficiently query them?
Thanks.
Hong
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, It appears I got confused between adding a comment to an existing thread and starting a new thread. I will re-post the problem to a new thread. And I apologize for any inconvenience to anyone because of my careless mistake.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mstor is a JavaMail provider, which means that you can use the standard JavaMail API to access it (in the same way as you are using the POP3 provider). There are samples of usage provided in the test cases of the library, as well as one very basic example here:
thanks, found the sample in the test :)
my mistake ...
mistake 1: downloaded the binary only package, not the src
mistake 2: was only looking through the api doc for help and found mboxfile and mboxencoder and immediately thought these 2 are the key class to look at
my sample of pop3 -> mbox that is working for those who are still lost(maybe only me)
//-----
String host = "localhost";
String username = "myuser";
String password = "mypass";
// Create empty properties
Properties props = new Properties();
props.setProperty("mail.pop3.port", "110");
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// mbox
URLName url = new URLName("mstor:E:/cygwin/home/user/mstor/mtest");
Properties p = new Properties();
// disable metadata..
MStorStore storeMbox;
storeMbox = new MStorStore(Session.getDefaultInstance(p), url);
storeMbox.connect();
// mbox
// copy from pop3 to mbox
Folder copy2 = storeMbox.getDefaultFolder().getFolder("Inbox");
//copy2.create(Folder.HOLDS_MESSAGES);
copy2.open(Folder.READ_WRITE);
Message messages[] = folder.getMessages();
copy2.appendMessages(messages);
// end copy
// Close connection
storeMbox.close();
folder.close(false);
store.close();
//----
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am working on a webmail client in Java and i saw mstor and i have some questions about it :).
can be mstore used to receive the messages from the pop3 server and store them locally?
I am using JavaMail to get the messages but the rroblem is that for a large email i ma getting OutOfMemory exception. :(
Caould you provide me with an example if mstor can be used to receive messahes from pop3?
Thank you,
akovari
Hi akovari,
You should definitely be able to retrieve messages from a POP3 server and store them locally using mstor - that is basically the purpose of mstor! :)
I'm not sure exactly of the OutOfMemory problem you are having, although its possibly a bug in mstor. If you can post me the stack trace when you get the exception then I might be able to track down what the problem is.
Also, you may want to try using small email messages for starters - its possible that if you have large emails (or attachments) that this is causing the problem.
regards,
ben
Hello,
I get the OutOfMemory message when i use JavaMail (without mstor.). I did not try it with mstor.
Can you please point me to some direction where i could find some examples on how to get the messages from the pop3 server using mstor?
thank you very mutch,
akovari
Akovari,
There are many examples available on the Web (and even included with the JavaMail distribution I believe?!) that will show you how to read messages from a POP3 server and write them to a local store (either mstor or otherwise). You might want to do a quick search to see what you can find.
Nevertheless I will try to make a quick example of how to do this and add it to the "Usage" section of the documentation here:
http://mstor.sourceforge.net/#usage (note that there is already an example of how to read from a local store)
regards,
ben
Hi, Fortuna and everyone else watching this forum
For my application, I need to be able to quickly query messages based on header values, for example Message-ID and In-Reply-To values. I might have a large amount of messages (let's say, over 1000), and they might be located in over a dozen folders, can mstor efficiently query them?
Thanks.
Hong
Sorry, It appears I got confused between adding a comment to an existing thread and starting a new thread. I will re-post the problem to a new thread. And I apologize for any inconvenience to anyone because of my careless mistake.
pop3 -> mbox
I need some help on this too...
// mbox section
File file = new File("c:/mailbox/MyStore");
MBox mbox(file,READ_WRITE)
// pop3 section
Session sessionPOP3 = Session.getDefaultInstance(props, null);
Store storePOP3 = sessionPOP3.getStore("pop3");
storePOP3.connect(host, username, password);
Folder folderPOP3 = storePOP3.getFolder("INBOX");
folderPOP3.open(Folder.READ_ONLY);
Message messagePop3[] = folderPOP3.getMessages();
// assuming we only care about the first message
Object content = messagePop3[0].getContent();
// assuming no attachment
// the part I'm lost...
InputStream is = messagePart.getInputStream();
BufferedReader reader =new BufferedReader(new InputStreamReader(is));
String thisLine=reader.readLine();
StringBuffer sb = new StringBuffer();
while (thisLine!=null)
{
sb.append(thisLine);
thisLine=reader.readLine();
}
mbox.appendMessage( MboxEncoder.encode(sb.toString().getBytes()) );
mbox.close();
or is there someother method to append a normal message to mbox?
Hello,
Mstor is a JavaMail provider, which means that you can use the standard JavaMail API to access it (in the same way as you are using the POP3 provider). There are samples of usage provided in the test cases of the library, as well as one very basic example here:
http://mstor.sourceforge.net/#usage
I'd suggest you do something similar to this example to obtain the appropriate javax.mail.Folder instance, and then append messages in the usual way.
regards,
ben
thanks, found the sample in the test :)
my mistake ...
mistake 1: downloaded the binary only package, not the src
mistake 2: was only looking through the api doc for help and found mboxfile and mboxencoder and immediately thought these 2 are the key class to look at
my sample of pop3 -> mbox that is working for those who are still lost(maybe only me)
//-----
String host = "localhost";
String username = "myuser";
String password = "mypass";
// Create empty properties
Properties props = new Properties();
props.setProperty("mail.pop3.port", "110");
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// mbox
URLName url = new URLName("mstor:E:/cygwin/home/user/mstor/mtest");
Properties p = new Properties();
// disable metadata..
MStorStore storeMbox;
storeMbox = new MStorStore(Session.getDefaultInstance(p), url);
storeMbox.connect();
// mbox
// copy from pop3 to mbox
Folder copy2 = storeMbox.getDefaultFolder().getFolder("Inbox");
//copy2.create(Folder.HOLDS_MESSAGES);
copy2.open(Folder.READ_WRITE);
Message messages[] = folder.getMessages();
copy2.appendMessages(messages);
// end copy
// Close connection
storeMbox.close();
folder.close(false);
store.close();
//----