• Post Reply Bookmark Topic Watch Topic
  • New Topic

How make mail message using JSP?  RSS feed

 
Nikolay Malevanniy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How make different(dependence of user, e.g. different username in title of body) mail message for many users using JSP page?
In other words - how I can using JSP for generate rich HTML mail messages?
Scenario: user make request to my server, servlet generate and send mail notification for subscribers on some event (e.g. new message in forum) and return response for user.

[This message has been edited by Nikolay Malevanniy (edited June 29, 2001).]
 
Julia Reynolds
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should write a custom tag into which you pass the user's email address, message subject, etc. In the custom tag put some code like this:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[])
throws Exception {
String host = args[0];
String from = args[1];
String to = args[2];
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getInstance(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);
}
}

This code is from JGURU: http://www.jguru.com/faq/view.jsp?EID=12858
Cheers,
Julia
[This message has been edited by Julia Reynolds (edited June 29, 2001).]
 
Nikolay Malevanniy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read jguru
But you don't understand me.
I want use JSP page for generate rich HTML text and send result by email.
Your example equivalent using servlets for generate HTML pages.
e.g. Scenario whith using custom tags (I don't know how did it)
<%Collection users = UserBean.getUserList()%>
<tag_for_mail_send name="user" collection="<%=users%>">
<jsp:useBean id="user" scope="page" type="UserBean"/>
Dear <%=user.getTitle()%> <%=user.getFullName()%>
<%--Reach HTML text--%>
</tag_for_mail_send>

[This message has been edited by Nikolay Malevanniy (edited June 29, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!