O'Reilly logo

Sams Teach Yourself J2EE™ in 21 Days by Peter Roxburgh, Andy Longshaw, Debbie Law, Dan Haywood, Martin Bond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending E-mails with Attachments

In the previous example, you used MIME multi-part messages to send a HTML message that displays an image. Another use of MIME is to send message attachments, such as MPEG videos, JPEG images, and plain text files. In this example, you will create a small command line application that sends a message with an attached XML file to a named recipient.

The code for this application is very similar to the previous applications. Today's lesson only explores those sections of code that differ from the previous examples, but you can still find a full listing at the end of this section or on the CD-ROM that accompanies this book.

This application starts by creating Properties, Session, and MimeMessage objects. It also adds ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required