日期:2014-05-19  浏览次数:20824 次

【紧急】已经加上mail.jar包 但是总是说找不到com/sun/mail/util/LineInputStream
想用JavaMail应经加上jar包 但是总是说找不到com/sun/mail/util/

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream

但是在WEB-INF下的lib中已经有mail.jar 我还加上了activation.jar

在referenced libraries 中也有mail.jar activation.jar 但还是报错。

点开referenced libraries 下的mail.jar 明明有 LineInputStream.class 



MyEclipse 还重新装过, 工作空间也换过。mail.jar 还下载了新的版本 

但是错误依旧



难道是代码的问题?
我记得这一段从网上copy的代码 还用过一次

package test;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
 
 
public class SendMail {
 
  //要发送Mail地址
  private String mailTo = null;
  //Mail发送的起始地址
  private String mailFrom = null;
  //SMTP主机地址
  private String smtpHost = null;
  //是否采用调试方式
  private boolean debug = false;
 
  private String messageBasePath = null;
  //Mail主题
  private String subject;
  //Mail内容
  private String msgContent;
 
  private Vector attachedFileList;
  private String mailAccount = null;
  private String mailPass = null;
  private String messageContentMimeType ="text/html; charset=gb2312";
 
  private String mailbccTo = null;
  private String mailccTo = null;
  /**
  * SendMailService 构造子注解。
  */
  public SendMail() {
  super();
   
  }
 
  private void fillMail(Session session,MimeMessage msg) throws IOException, MessagingException{
   
  String fileName = null;
  Multipart mPart = new MimeMultipart();
  if (mailFrom != null) {
  msg.setFrom(new InternetAddress(mailFrom));
  System.out.println("发送人Mail地址:"+mailFrom);
  } else {
  System.out.println("没有指定发送人邮件地址!");
  return;
  }
  if (mailTo != null) {
  InternetAddress[] address = InternetAddress.parse(mailTo);
  msg.setRecipients(Message.RecipientType.TO, address);
  System.out.println("收件人Mail地址:"+mailTo);
  } else {
  System.out.println("没有指定收件人邮件地址!");
  return;
  }
   
  if (mailccTo != null) {
  InternetAddress[] ccaddress = InternetAddress.parse(mailccTo);
  System.out.println("CCMail地址:"+mailccTo);
  msg.setRecipients(Message.RecipientType.CC, ccaddress);
  }
  if (mailbccTo != null) {
  InternetAddress[] bccaddress = InternetAddress.parse(mailbccTo);
  System.out.println("BCCMail地址:"+mailbccTo);
  msg.setRecipients(Message.RecipientType.BCC, bccaddress);
  }
  msg.setSubject(subject);
  InternetAddress[] replyAddress = { new InternetAddress(mailFrom)};
  msg.setReplyTo(replyAddress);