我是初学者,向各位前辈请教!

luoxxhh 2001-08-29 11:16:22
我把javamail api放在d:\javamail下,
jaf放在D:\jaf下,然后我在DOS下SET CLASSPATH,命令如下:
set classpath=.;d:\javamail\imap.jar;d:\javamail\mail.jar;d:\javamail\mailapi.jar;d:\javamail\pop3.jar;d:\javamail\smtp.jar;D:\jaf\activation.jar;
然后我这样发邮件:

mail.jsp:
<HTML><BODY><FORM action="sendmail.jsp" method="post">
<TABLE align="center" width="54%">
<TR>
<TD> To:
<INPUT name="to" size="25">
From:
<INPUT name="from" size="25">
</TD>
</TR>
<TR>
<TD colspan="2" height="25"> Subject:
<INPUT name="subject" size="50">
</TD>
</TR>
<TR>
<TD width="64%">Message:<BR>
<TEXTAREA name="text" rows=15 cols=70></TEXTAREA>
   </TD>
   </TR>
   </TABLE>
<div align="center">
<INPUT type="submit" name="cb_submit" value=" Send ">
  
<INPUT type="reset" name="cb_reset" value=" Clear ">
  </div>
</FORM> </HTML>


sendmail.jsp:
<%@ page import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*"
%>
<html> <head>
<TITLE>JSP meets JavaMail, what a sweet combo.</TITLE>
</HEAD>
<BODY>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.jspinsider.com");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from")));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter("to")));
newMessage.setSubject(request.getParameter("subject"));
newMessage.setSentDate(new Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage);
%>
<P>Your mail has been sent.</P>
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%>
</BODY>
</HTML>

源程序来自精华区,相信不会错.
我用resin,但提示出错为:

javax.mail 不存在
import javax.mail.*;
^
sendmail.jsp:12: 包 javax.mail.internet 不存在
import javax.mail.internet.*;
^
sendmail.jsp:13: 包 javax.activation 不存在
import javax.activation.*;
^
sendmail.jsp:13: 不能解析符号
符号:类 Session
位置:类 in _371._sendmail__jsp
Session sendMailSession;

请问是什么地方错了呢?我应该怎么处理那几个JAR文件?
...全文
10 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-08-29 11:16
社区公告
暂无公告