Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

jGuru: Fundamentals of the JavaMail API

 


[Short Course| About This Short Course]

Exercise Outline

Welcome to the jGuru exercises on the JavaMail API.

The JavaMail exercises demonstrate how to setup your JavaMail environment, send and receive mail through SMTP and POP respectively, and show how to work with attachments and filters.

About Exercises

A jGuru exercise is a flexible exercise that provides varying levels of help according to the student's needs. Some students may complete the exercise using only the information and the task list in the exercise body; some may want a few hints (Help); while others may want a step-by-step guide to successful completion (Solution). Since complete solutions are provided in addition to help, students can skip an exercise and still complete later exercises that require the skipped one(s).

The Anatomy of an Exercise

Each exercise includes a list of any prerequisite exercises, a list of skeleton code to start with, links to necessary API pages, and a text description of the exercise's educational goal. In addition, buttons link you to the following information:

  • Help: Gives you help or hints on the current exercise, an annotated solution. For ease of use, the task information is duplicated on the help page with the actual help information indented beneath it.
  • Solution: The <applet> tag and Java source resulting in the expected behavior.
  • API Documentation: A link directly to any necessary online API documentation.

Exercise Design Goals

There are three fundamental exercise types that you may encounter:

"Blank screen"
You are confronted with a "blank screen" and you create the entire desired functionality yourself.
Extension
You extend the functionality of an existing, correctly-working program.
Repair
You repair undesirable behavior in an existing program.

To make learning easier, exercises, where possible, address only the specific technique being taught in that exercise. Irrelevant, unrelated, and overly complex materials are avoided.

JavaMail Exercises

  1. Setting Up Your JavaMail Environment

    Install the JavaMail reference implementation.

    Educational goal(s):

    • Setup your environment to compile and run JavaMail programs
    • Explore the demonstration programs that come with the reference implementation

  2. Sending Your First Message

    This exercise has you write the code necessary to send a mail message.

    Educational goal(s):

    • Learn about the Session class
    • Learn to create a MimeMessage
    • Learn to create an InternetAddress
    • Learn to send mail with the Transport class

  3. Checking for Mail

    This exercise has you use the JavaMail API to read your mail.

    Educational goal(s):

    • Learn about the Store class
    • Learn to get a Folder from a store
    • Learn to get Message objects from a folder

  4. Replying to Mail

    This exercise teaches you how to setup a reply message.

    Educational goal(s):

    • Learn to copy the necessary header information for a reply message
    • Learn to copy the original message content for a reply

  5. Sending Attachments

    This exercise teaches you how to include an attachment with your message.

    Educational goal(s):

    • Learn about the BodyPart and MimeBodyPart classes
    • Learn to combine parts in a Multipart
    • Learn to work with data sources to specify attachments

  6. Sending HTML Messages with Images

    This exercise teaches you how to send HTML messages, directly referencing included attachments.

    Educational goal(s):

    • Learn how to send HTML messages
    • Learn to reference related parts from an HTML message

Copyright 1996-2001 jGuru.com. All Rights Reserved.