Blog: Tech Talk

agsdix-fas fa-home

Blog: Home

agsdix-fas fa-pen-fancy

Blog: CEO's Corner

agsdix-fas fa-code

Blog: Tech Talk

Blog: Product Releases

Blog: Conversion

arrow left circle icon Blog: Tech Talk

Viewing an Email Attachment within a Web Browser

by | Apr 24, 2012


A previous tech tip described how to write a servlet to view any document supported by the RasterMaster Imaging SDK library in a standard Web browser.

Now that you know how to convert various document formats (MS-Word, PDF, TIFF) to a web-viewable format, you can use this technology to create a WebMail client. The JavaMail extension package will help do this for you.

Using the JavaMail Quick-Start guide at JavaWord, you can quickly learn how to open the contents of a Pop3 Mail Server.

You now need to convert this code to run as a servlet. Instead of printing to the console, write a servlet to process requests and write out the messages to an HTML stream.
The fun part comes when you have an attachment that you want to make viewable. Like most commercial web mail services, you want to provide a link to the attachment to let the user 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, you can display the contents of the document directly in the browser. You 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 links directly to the file as follows:
http://server/SnowMail/attachments/sample.pdf

The other link is an embedded HTML tag which points to the image conversion servlet as in the example below: