View Full Version : how to send mail to Microsoft Outlook automatically using Java Server Pages
santosh_tamse
02-17-2009, 04:25 AM
hi all
hi especially to those who is reading this question
i m writing a program in java server pages in which i hav to send a mail automatically to Microsoft Outlook using Java Server Pages plz help me for this. i hav tried a lot but i failed.i want a Java Server Pages code for that so plz give me a response as fast as possible
servlet
02-17-2009, 06:12 AM
i m writing a program in java server pages in which i have to send a mail automatically to Microsoft Outlook using Java Server Pages
You don't send mail to Microsoft outlook, but outlook gets it from pop server.
It's good practice to not to write Javamail code inside JSP, instead you can create a mail helper and use it inside JSP.
Look at Commons email library (http://commons.apache.org/email/)
It's quite easy, import the org.apache.commons.mail.SimpleEmail into your JSP using JSP page directive (http://www.jsptube.com/jsp-tutorials/jsp-page-directive.html)
<%@page import=”org.apache.commons.mail.SimpleEmail”/>
<%
SimpleEmail email = new SimpleEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();
%>
servlet
02-18-2009, 06:24 AM
Host name is the name of the server where mail server is running.
If you are running mail server on you local PC, you can user 'localhost' as host name. You can use IP address too.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.