wood burning stoves 2.0*
The moose likes JSP and the fly likes Mail variables are not being resolved to a type ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Mail variables are not being resolved to a type !" Watch "Mail variables are not being resolved to a type !" New topic

Mail variables are not being resolved to a type !

Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
I am trying to use the code below to send an email using JSP , but for all the variables i.e


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");
InternetAddress to = new InternetAddress("you@hotmail.com");
message.addRecipient(Message.RecipientType.TO, to);

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


A Message has been sent.
Check your inbox.

Click here to send another!

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60755

Why on earth would you do this in a JSP? Move the Java code to a Java class where it belongs.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Mail variables are not being resolved to a type !
Similar Threads
Sending Mail JSP
Java Mail - How to send to Multiple recipients
javamail jsp problem
Sending mail - Y! Mail - failed
Sending mails