Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to send mail to Microsoft Outlook automatically using Java Server Pages

    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

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    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

    It's quite easy, import the org.apache.commons.mail.SimpleEmail into your JSP using JSP page directive


    Code:
    <%@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();
    %>
    Last edited by servlet; 02-17-2009 at 06:16 AM.

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •