Posted By:
Sam_Anjos
Posted On:
Tuesday, July 15, 2003 01:43 PM
text I have the following javabean which creats a html message with a hyperlink loaded with information passed by a jsp form. package IRURegistrationProject; // import the necessary packages import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class SMTPMailBean { private String submit; private Properties props ; private Session s; private Message message; private InternetAddress from; private InternetAddress to; /** Creates new SMTPBean */ public SMTPMailBean() { } // method used to cre
More>>
text
I have the following javabean which creats a html message with a hyperlink loaded with information passed by a jsp form.
package IRURegistrationProject;
// import the necessary packages
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SMTPMailBean {
private String submit;
private Properties props ;
private Session s;
private Message message;
private InternetAddress from;
private InternetAddress to;
/** Creates new SMTPBean */
public SMTPMailBean() {
}
// method used to create all the objects necessary to use JavaMail
// the strings passed into the method are fields passed in the url.
public void sendMail(String fn,String ln,String st,String cert,
String stu,String affil,String div,String addr,
String city,String ph1,String ph2,String zip1,
String zip2,String wrk1, String wrk2,
String fax1,String fax2,String email)
throws AddressException, MessagingException
{
// create a session object
props = new Properties();
rops.put("mail.smtp.host","hostmailserver");
s = Session.getInstance(props,null);
// create MimeMessage object
message = new MimeMessage(s);
// create the from InternetAddress object
from = new InternetAddress("eprints@merlin.mb.ca");
message.setFrom(from);
//create the to InternetAddress object
to = new InternetAddress("toEmail");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("New IRU Patron");
message.setSentDate(new Date());
String body = "
" +
"
"+
"
"+
"
There is a new Patron Record
" +
"
"fname="+fn + "&lname="+ln +"&stat="+st+ "&certif="+cert+"&student="+stu+"&affil="+affil+ "&devision="+div+"&address="+addr+ "&city="+city+"&phone="+ph1+"-"+ph2+ "&zip="+zip1+"-"+zip2+"&work="+wrk1+"-"+wrk2 "&fax="+fax1+"-"+fax2+"&email="+email + "">View Record
"+ "
";
message.setContent(body, "text/html");
// transport object is created and sends the message
Transport.send(message);
}
}
It sends the email in my xp machine running tomcat 4.1.24 and jdk 1.4, but when I tryed to use the same code in a solaris machine running tomcat 4.0.4 and jdk 1.2 I get the following error
javax.servlet.ServletException: Sending failed;
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html
I don't quite understand why this code makes the solaris machine choke... any help would be welcomed.
Thank You.
<<Less