JavaMail Client on the NetBeans Platform (Step 1)
By Geertjan on Jan 29, 2007
- Download JavaMail here. Next, download the Java Activation Framework here.
- Use the Java Project with Existing Sources template, to create an application from the sources at demo/client in the unzipped JavaMail download. Refactor the default package, where all the sources end up, to a package name like "client". Move simple.mailcap to the project root (use the Files window to do this, putting the simple.mailcap file in the same place where build.xml is found).
- Use the Library Manager to create a library where you add the JAR files for JavaMail and the Java Activation Framework. Attach that library to your application's Libraries node.
You should now see this in the Projects window:
You can only see simple.mailcap if you look in the Files window.
- Right-click the application in the Projects window, choose Properties and add something like this in the Run tab's Arguments field:
Doesn't have to be imap. See JavaMail docs for other supported protocols.
- Run the project. If the Output window shows error messages about 'login methods not being found' (which is a rather obscure message), see this tip:
Once the application is successfully deployed, you'll be able to view your e-mails in your simple client. However, I encountered the same NPE as someone else (here). It starts like this:
at MessageViewer.getBodyComponent(MessageViewer.java:199) at MessageViewer.setMessage(MessageViewer.java:104)
This happens when I want to open a message in the lower part of the client. However, for other types of messages, there's no problem. Need to investigate this. Anyway, for the successfully opened messages, the client looks as follows:
Now that we have a simple client, we are able to examine its content and see how best to port it to the NetBeans Platform, described in part 2.