hi all
i am trying to intigrate email functionality in Abstract Portal component
I am getting error message
this is my code
String myhost = "USCNT0417";
String mailfrom = "srinivasrao@mailcity.com";
String mailto = "asomayajula@deloitte.com" ;
String subject = "This is test message";
String mailmessage = "Hi This is the message i am sending from the Abstract portal component object" ;
InitialContext ctx = null;
MimeBodyPart bodyPart = null;
Address[] address = null;
// Message msg = null;
//Multipart mp = null;
Transport tr = null;
Session sess = null ;
try {
ctx = new InitialContext();
sess = (Session) javax.rmi.PortableRemoteObject.narrow(initctx.lookup("java:comp/env/mail/MailSession"), request.getComponentSession().getHttpSession().getClass());
//sess = (Session) javax.rmi.PortableRemoteObject.narrow(ctx.lookup("MailSession"), Session.class);
//Message msg = new MimeMessage(sess);
Message msg = new MimeMessage(sess);
msg.setFrom(new InternetAddress(mailfrom));
// msg.setRecipients(Message.RecipientType.TO, extractRecipientAddresses(mailto));
msg.setSubject(subject);
msg.setRecipient(Message.RecipientType.TO,new InternetAddress(mailto));
msg.setContent(mailmessage, "text/plain");
msg.setSentDate(new GregorianCalendar().getTime());
msg.saveChanges();
tr = sess.getTransport("smtp");
tr.connect(myhost, "", "");
address = msg.getAllRecipients();
tr.sendMessage(msg, address);
tr.close();
response.write("your mail was delevered");
}catch(Exception E){response.write("your mail was not delevered the error is :" + E.toString());}
if this works i has to copy this code into main class and has to use runtime parameters
thank u
regards
srinivas ayyala