如题。  

解决方案 »

  1.   

    javamail一段代码public static void main(String[] args) throws Exception{
    Properties props = new Properties();
    props.setProperty("mail.smtp.auth", "true");
    props.setProperty("mail.transport.protocol", "smtp");
    props.setProperty("mail.host", "smtp.163.com");
    Session session = Session.getInstance(props,
    new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication(){
    return new PasswordAuthentication("username","pwd");//填"用户名","密码"
    }
    }
    );
    session.setDebug(true);Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress("[email protected]"));//填发送人email地址
    msg.setSubject("subject");//填email标题
    msg.setRecipients(RecipientType.TO,  
    InternetAddress.parse("[email protected]"));//接收人email地址
    msg.setContent("content");//email正文Transport.send(msg);
    }对应位置填你的email地址,用户名,密码等信息。一个简单的发送email的代码了,项目里要加入mail.jar
    jar包通过这个地址下载
    http://www.oracle.com/technetwork/java/javamail/index-138643.html
      

  2.   

     报错:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
    at javax.mail.Session.loadProvidersFromStream(Session.java:928)
    at javax.mail.Session.access$000(Session.java:174)
    at javax.mail.Session$1.load(Session.java:870)
    at javax.mail.Session.loadResource(Session.java:1084)
    at javax.mail.Session.loadProviders(Session.java:889)
    at javax.mail.Session.<init>(Session.java:210)
    at javax.mail.Session.getInstance(Session.java:232)
    at org.test.youjian.Test.main(Test.java:144)什么类没编译。 架包都导过了