• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mail variables are not being resolved to a type !

 
Mishaal Khan
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use the code below to send an email using JSP , but for all the variables i.e

Session
MimeMessage
InternetAddress

its throwing exception that "cannot be resolve to a type " . I am using Eclipse and in build path it includes the classpath to mail.jar and activation.jar.

Here is the JSP code:

<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "localhost");
Session s = Session.getInstance(props,null);

MimeMessage message = new MimeMessage(s);

InternetAddress from = new InternetAddress("me@example.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("you@hotmail.com");
message.addRecipient(Message.RecipientType.TO, to);

message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");

Transport.send(message);
%>
<html>

A Message has been sent.
Check your inbox.


Click here to send another!


</html>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth would you do this in a JSP? Move the Java code to a Java class where it belongs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic