|
[Exercise | API Docs | Short Course| Exercises] Help is available for each task. Task 1Starting with the skeleton code, get the system Properties props = System.getProperties(); Task 2Add the name of your SMTP server to the properties for the
props.put("mail.smtp.host", host);
Task 3Get a Session session = Session.getDefaultInstance(props, null); Task 4Create a MimeMessage message = new MimeMessage(session); Task 5Set the from field of the message. message.setFrom(new InternetAddress(from)); Task 6Set the to field of the message.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
Task 7Set the subject of the message.
message.setSubject("Hello JavaMail");
Task 8Set the content of the message.
message.setText("Welcome to JavaMail");
Task 9Use a Transport.send(message); Task 10Compile and run the program, passing your SMTP server, from address, and to address on the command line. java MailExample SMTP.Server from@address to@address Task 11Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...). Copyright 1996-2001 jGuru.com. All Rights Reserved. | ||||||||||||||
|
| ||||||||||||