Results 1 to 2 of 2
- 03-09-2009, 02:24 PM #1
[SOLVED] Access to default session deniedAccess to default session denied
<%@ page import="javax.mail.PasswordAuthentication,java.uti l.Date,java.util.Properties,javax.activation.DataH andler,javax.activation.FileDataSource,javax.mail. Message,javax.mail.MessagingException,javax.mail.M ultipart,javax.mail.Session,javax.mail.Transport,j avax.mail.internet.InternetAddress,javax.mail.inte rnet.MimeBodyPart,javax.mail.internet.MimeMessage, javax.mail.internet.MimeMultipart" %>
<%
String from = "abcd@gmail.com";
String to[] = {"abcd@gmail.com"};
String subject = "Password Recovery";
String bodyText = "The information contained in this electronic message and any attachments to this message are intended for exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at xyz@mycony.com immediately and destroy all copies of this message and any attachments. The views expressed in this E-mail message / Attachments, are those of the individual sender.";
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
Session s = Session.getDefaultInstance(props,new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("abcd@gmail.com", "pwd1234");
}
});
try {
MimeMessage message = new MimeMessage(s);
message.setFrom(new InternetAddress(from));
for(int i=0;i<to.length;i++){
message.setRecipient(Message.RecipientType.TO, new InternetAddress(to[i]));
message.setSubject(subject);
message.setSentDate(new Date());
//
// Set the email message text.
//
MimeBodyPart messagePart = new MimeBodyPart();
messagePart.setText(bodyText);
//
// Set the email attachment file
//
/*MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fileDataSource = new FileDataSource(filename) {
@Override
public String getContentType() {
return "application/octet-stream";
}
};
attachmentPart.setDataHandler(new DataHandler(fileDataSource));
attachmentPart.setFileName(filename);*/
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messagePart);
// multipart.addBodyPart(attachmentPart);
message.setContent(multipart);
Transport.send(message);
}
} catch (MessagingException e) {
e.printStackTrace();
}
%>
Access to default session denied
Thanks and Regards,
ABB
- 03-10-2009, 02:12 PM #2
Similar Threads
-
Access Remote Session Bean from an separate web app
By kiyoharatakuya in forum Enterprise JavaBeans (EJB)Replies: 4Last Post: 04-24-2009, 04:46 PM -
How to Kill session at application context level by using session Id
By Kishore.Kumar in forum Java ServletReplies: 1Last Post: 04-22-2009, 12:20 AM -
How do I create session for a user when S/he login and expire the session.
By dpk_vash in forum Web FrameworksReplies: 2Last Post: 12-23-2008, 07:35 PM -
want default value in ComboBox !!
By Java.child in forum SWT / JFaceReplies: 0Last Post: 09-29-2008, 10:57 PM -
Default Button
By hiranya in forum AWT / SwingReplies: 2Last Post: 11-01-2007, 07:08 PM
Bookmarks