new Address[]()那里报The left-hand side of an assignment must be a variable错误、
new Address[]()那里报The left-hand side of an assignment must be a variable错误、
package com.sxt.mail;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class MailConnection {
\x05public static void main(String[] args) throws Exception {
\x05\x05Properties props = new Properties();
\x05\x05props.setProperty("mail.debug","");
\x05\x05Session session = Session.getInstance(props);
\x05\x05Message msg = new MimeMessage(session);
\x05\x05msg.setText("你好吗?");
\x05\x05msg.setFrom(new InternetAddress("meimei@sohu.com"));
\x05\x05Transport transport = session.getTransport();
\x05\x05transport.connect("smtp.sohu.com",25,"wstc","123456");
\x05\x05transport.send(msg,new Address[](new InternetAddress("wstc@sohu.com")));
\x05\x05transport.close();
\x05}
}
Address[](new InternetAddress("wstc@sohu.com"))-->
Address[]{new InternetAddress("wstc@sohu.com")}