Cannot Find Symbols: 'getDefaultInstance' 'MimeMessage' 'RecipientType' !!
Hi all,
I'm trying to send mail using Sun Java Studio Ceator 2 IDE
using this code
public String cmdSend_action(){
//TODO: set the from, to addresses and the mail server
String from ="******@yahoo.com";// from address
String to ="********@*******.com";// to address
String host ="*****.**.***.*****.com";
// please note that if your mail server requires authentication,
// this code may not work
try
{
// Get system properties
Properties props = (Properties)System.getProperties().clone();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance(props,null);
// Define message
MimeMessage message =new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
}
catch (java.io.IOException ex)
{
// in the case of an exception, print a message to the output log
log("ERROR SENDING EMAIL:"+ex);
error("ERROR SENDING EMAIL: " + ex.getMessage());
}
catch (Exception e)
{
log("ERROR SENDING EMAIL:"+e);
error("ERROR SENDING EMAIL: " + e.getMessage());
}
returnnull;
}
but as seen in the below screen shot, the IDE cannot find some symbols
http://i18.tinypic.com/4552ez8.gif
although I've fixed imports & that's my imports
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.Page;
import javax.faces.FacesException;
import com.sun.rave.web.ui.component.Label;
import com.sun.rave.web.ui.component.TextArea;
import com.sun.rave.web.ui.component.Button;
import com.sun.rave.web.ui.component.MessageGroup;
import javax.jms.Message;
import javax.jms.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
import java.net.SocketPermission;
I downloaded the latest version of javamail-1.4 & jaf-1.1
and coppied the mail.jar & activation.jar to SunAppServer8\domains\creator\lib & SunAppServer8\lib directories
but the problem remains!
I followed these instructions http://java.sun.com/products/javamail/classpath-NT.html
to set my CLASSPATH as shown in this screen shot:
http://i17.tinypic.com/2vah1j4.gif
but the problem remains!!
I've also added these to the security policy file used by the application
grant{
// following two permissions allow
// access to default config files
permission java.io.FilePermission
"...path/SunAppServer8/domains/creator/lib/mail.jar","read";
permission java.io.FilePermission
"...path/SunAppServer8/domains/creator/lib/activation.jar","read";
// following to use SMTP
permission java.net.SocketPermission
"SMTPHOST:25","connect,resolve";
// following to use IMAP
permission java.net.SocketPermission
"IMAPHOST:143","connect,resolve";
// following to use POP3
permission java.net.SocketPermission
"POP3HOST:110","connect,resolve";
// following needed if System.getProperties() is used
permission java.util.PropertyPermission
"*","read,write";
};
but also the problem remains!!!!!
Please help me with this so annoying problem
I'm stucked in it for weeks
Thanks in advance.

