Now that we know how to convert various document formats (MS-Word, PDF, TIFF) to a web-viewable format, Let's use this technology to create a really slick WebMail client. The JavaMail extension package will help do this for us.
Using the JavaMail Quick-Start guide at JavaWord, We quickly learn how to open the contents of a Pop3 Mail Server.
Converting this code to run as a servlet is easy. Instead of printing to the console, we can write a servlet to process requests and write out the messages to an HTML stream.
The fun part comes when we have an attachment. Like most commercial web mail services, we want to provide a link to the attachment, so the user can download the document to their machine. In addition, if the attachment happens to be a document that is handled by Snowbound Software's RasterMaster Imaging SDK, we can display the contents of the document directly in the browser. We can also provide navigational links for multiple page files.
To provide this functionality, The Pop3 Servlet downloads all of the attachments of an email to the Server's file system. It then generates two links. One is the direct link to the file, Something like.
http://server/SnowMail/attachments/sample.pdf
The other link is an embedded HTML <img> tag, which points to our image conversion servlet, similar to the one we wrote in the last post.
<img src="http://server/SnowMail/ImageServlet?filename=sample.pdf">
Here's a screen shot of the result.
-Alex
Comments