文档介绍:×÷Õߣºjeru
email: jeru@
ÈÕÆÚ£º2001-1-9 18:37:32
Here is the code to send an attachment:
import ;
import .*;
import ..*;
import .*;
public class AttachExample {
public static void main (String args[])
throws Exception {
String host = args[0];
String from = args[1];
String to = args[2];
String fileAttachment = args[3];
// Get system properties
Properties props = ();
// Setup mail server
("", host);
// Get session
Session session =
(props, null);
// Define message
MimeMessage message =
new MimeMessage(session);
(
new Address(from));
(
,
new Address(to));
(
"Hello JavaMail Attachment");
// create the message part
MimeBodyPart messageBodyPart =
new MimeBodyPart();
//fill message
("Hi");
Multipart multipart = new MimeMultipart();