html邮件发送:static Properties t= new Properties();// 协议t.put("mail.transport.protocol", "smtp");// 端口t.put("mail.smtp.port", "25");// 主机t.put("mail.smtp.host", "smtp.163.com");// 认证t.put("mail.smtp.auth", "true");// 调试prop.put("mail.debug", "true");// 发送html邮件public static void sendHtmlEmail() throws Exception {//创建会话对象62616964757a686964616fe58685e5aeb931333365656566Session session = Session.getDefaultInstance(t, new MyAuthenticator("user","pwd"));//邮件对象MimeMessage message = new MimeMessage(session);message.setFrom(new InternetAddress("xx@qq.com"));message.setRecipient(RecipientType.CC, new InternetAddress("shoudao@qq.com"));message.setSentDate(new Date());message.setSubject("三国杀..............");message.setContent("度娘", "text/html;charset=GBK");message.saveChanges();// 发送Transport.send(message);},首先选中接口类型名字,右键菜单,如图然后会出来一个类关系树形图,如图这样你就能轻松查看有哪些类实现该接口该方法不仅仅适用接口,也可以查找某个类的子父级关系,html邮件发送:static Properties t= new Properties();// 协议t.put("mail.transport.protocol", "smtp");// 端口t.put("mail.smtp.port", "25");// 主机t.put("mail.smtp.host", "smtp.163.com");// 认证t.put("mail.smtp.auth", "true");// 调试32313133353236313431303231363533e78988e69d8331333361326335prop.put("mail.debug", "true");// 发送html邮件public static void sendHtmlEmail() throws Exception {//创建会话对象Session session = Session.getDefaultInstance(t, new MyAuthenticator("user","pwd"));//邮件对象MimeMessage message = new MimeMessage(session);message.setFrom(new InternetAddress("xx@qq.com"));message.setRecipient(RecipientType.CC, new InternetAddress("shoudao@qq.com"));message.setSentDate(new Date());message.setSubject("三国杀..............");message.setContent("度娘", "text/html;charset=GBK");message.saveChanges();// 发送Transport.send(message);}本回答被网友采纳,使用模板变量。{0}在执行时会被替换为链接,金陵图(韦庄)www.mh456.com防采集。
好久没用过了,我记得是可以设置邮件是文本格式,还是HTML格式。设为HTML格式就行了。4226本回答被网友采纳
我说你这种想法不对! 我不能给你提供具体的解决方案,我给你一个思路! 首先你需要Exchange 200x 中配置 SMTP 连接器; 然后使用JAVA的mail包写发邮件的程序。
内容来自www.mh456.com请勿采集。