Skip to Content
Former Member
Apr 14, 2004 at 05:49 PM

Very Urgent Please Help me


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 = "";

String mailto = "" ;

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.setRecipient(Message.RecipientType.TO,new InternetAddress(mailto));

msg.setContent(mailmessage, "text/plain");

msg.setSentDate(new GregorianCalendar().getTime());


tr = sess.getTransport("smtp");

tr.connect(myhost, "", "");

address = msg.getAllRecipients();

tr.sendMessage(msg, address);


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


srinivas ayyala