注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发JSP → 文章内容

一种优秀的邮件发送工具包

作者:佚名 来源:不详 发布时间:2007-11-30 0:00:24

  你是不是还在手工使用JavaMail API开发邮件程序?来看看这个工具吧,发送邮件只需要几行代码就可以搞惦!

// create a new Smtp instance providing hostname of SMTP serverSmtp smtp = new Smtp("smtp.myserver.com");//smtp.login(user,password);// create and address the e-mail. message EmailMessage message = new EmailMessage(); message.setTo("mjones@myserver.com"); message.setFrom("jsmith@myserver.com"); message.setSubject("Meeting today at 8"); message setBody("see you then"); // connect to SMTP server and send email messagesmtp.send(message);// disconnect from SMTP serversmtp.disconnect();

添加一个附件:

Attachment a = new Attachment(new File("/usr/home/report.doc"));message.addAttachment(a);

发送HTML格式的邮件:

message.setContentType("text/html");

怎么样,简单吧!这个包中还包括POP3、FTP、IMAP4等使用工具。可以在下面网站下载:

http://www.jscape.com/inetfactory/index.html
更多内容请看PCdog.com--垃圾邮件专题

  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved