www.pudn.com > JMail4Email.rar > SendMessageAction.java


package ezmail; 
 
import javax.servlet.ServletContext; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import javax.servlet.http.HttpSession; 
 
import javax.mail.Session; 
 
public class SendMessageAction implements Action { 
 
	public SendMessageAction() { 
	} 
 
	/** 
	 *  Performs the following steps... 
	 *  
    *
  1. ....
  2. *
* * The data is then placed in the user's session. The attribute is named * Constants.DATA */ public void perform(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws ActionException { try { HttpSession theHttpSession = request.getSession(); // retrieve the mail session Session mailSession = (Session) theHttpSession.getAttribute(Constants.MAIL_SESSION); UserInfo theUserInfo = (UserInfo) theHttpSession.getAttribute(Constants.USER_INFO); String from = theUserInfo.getEmailAddress(); String to = request.getParameter("to"); String subject = request.getParameter("subject"); String messageText = request.getParameter("message_text"); MailHelper.sendMessage(mailSession, from, to, subject, messageText); } catch (Exception exc) { exc.printStackTrace(); throw new ActionException(exc.getMessage()); } } }