首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

javamail邮件开发入门(一)

2012-07-24 
javamail邮件开发入门(1)简单的邮件发送:public static void main(String[] args) throws UnsupportedEnco

javamail邮件开发入门(1)

简单的邮件发送:

public static void main(String[] args) throws UnsupportedEncodingException, AddressException {        Properties props = new Properties();        props.put("mail.transport.protocol", "smtp");        props.put("mail.smtp.auth ", "true");        Session session = Session.getInstance(props, null);        session.setDebug(true);        try {            Transport transport = session.getTransport();            transport.connect("smtp.qq.com", "10086@qq.com", "888888");            MimeMessage msg = new MimeMessage(session);            msg.setFrom(InternetAddress.parse(""yonge.gao"<10086@qq.com>")[0]);            //msg.setRecipients(Message.RecipientType.TO, "10086@qq.com,10010@qq.com");            msg.setSubject(MimeUtility.decodeText("第二次实验"));            msg.setSentDate(new Date());            msg.setText("Hello, World!\n");            transport.sendMessage(msg, InternetAddress.parse("10086@sohu.com"));            transport.close();        } catch (MessagingException mex) {            System.out.println("send failed, exception: " + mex);        }    }

?

热点排行