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 j
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 02:02:18
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 j
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("[email protected]"));
\x05\x05Transport transport = session.getTransport();
\x05\x05transport.connect("smtp.sohu.com",25,"wstc","123456");
\x05\x05transport.send(msg,new Address[](new InternetAddress("[email protected]")));
\x05\x05transport.close();
\x05}
}
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 j
Address[](new InternetAddress("[email protected]"))-->
Address[]{new InternetAddress("[email protected]")}