I have a question in JavaMail.
I don't know why the page generated by servlet doesn't even show up even the
java file was compiled successfully. I mean even though JavaMail function
doesn't work properly, at lease the html part should show up in the page...
Does anyone know why it doesn't work with this code?
Please help me!
--- Here is the code ---
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class JavaMail {
public static void main(String args[]) {
Properties props = new Properties();
props.put("mail.smtp.host","xxx.xxx.com");
Session session = Session.getDefaultInstance(props,null);
try {
MimeMessage msg = new MimeMessage(session);
InternetAddress[] tolist = new InternetAddress[2];
tolist[0] = new InternetAddress("[EMAIL PROTECTED]",
MimeUtility.encodeWord("recipient1","iso-2022-jp","B"));
tolist[1] = new InternetAddress("[EMAIL PROTECTED]",
MimeUtility.encodeWord("recipient2","iso-2022-jp","B"));
msg.setRecipients(Message.RecipientType.TO,tolist);
msg.setFrom(new InternetAddress("[EMAIL PROTECTED]",
MimeUtility.encodeWord("sender","iso-2022-jp","B")));
String subject = "divided into two part";
msg.setSubject(MimeUtility.encodeText(subject,"iso-2022-jp","B"));
String message = " 1st line \r\n 2nd line \r\n 3rd
line \r\n";
msg.setContent(message,"text/plain;
charset=\"iso-2022-jp\"");
Transport.send(msg);
}
catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
}
--------------------------------
Taro
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com