Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: please any one help in this application ,this simple application can you send message

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Location
    Egypt
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please any one help in this application ,this simple application can you send message

    please any one help in this application ,this simple application can you send message to E-mail but found some problem I can't solve it

    <html>
    <body>
      <form action="sendMail.jsp" method="post">
        <table cellspacing="2" cellpadding="2" border="1">
          <tr>
            <td>To:</td>
            <td>
              <input type="text" name="to" size="30" maxlength="30">
            </td>
          </tr>
          <tr>
            <td>From:</td>
            <td>
              <input type="text" name="from" size="30" maxlength="30">
            </td>
          </tr>
          <tr>
            <td>Subject</td>
            <td>
              <input type="text" name="subject" size="30" maxlength="30">
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <textarea cols="40" rows="10" name="body"></textarea>
            </td>
          </tr>
          <tr>
            <td>
              <input type="submit" name="submit" value="Submit">
              <input type="Reset">
            </td>
          </tr>
        </table>
      </form>
    </body>
    </html>

    <html>
      <head>
        <title>JSP JavaMail Example </title>
      </head>
     
    <body>
     
    <%@ page import="java.util.*" %>
    <%@ page import="javax.mail.*" %>
    <%@ page import="javax.mail.internet.*" %>
    <%@ page import="javax.activation.*" %>
     
    <%
        String host = "smtp.gmail.com";
        String to = request.getParameter("to");
        String from = request.getParameter("from");
        String subject = request.getParameter("subject");
        String messageText = request.getParameter("body");
        boolean sessionDebug = false;
     
        Properties props = System.getProperties();
        props.put("mail.host", host);
        props.put("mail.transport.protocol", "smtp");
     
        Session mailSession = Session.getDefaultInstance(props, null);
     
        mailSession.setDebug(sessionDebug);
     
        Message msg = new MimeMessage(mailSession);
     
        msg.setFrom(new InternetAddress(from));
        InternetAddress[] address = {new InternetAddress(to)};
        msg.setRecipients(Message.RecipientType.TO, address);
        msg.setSubject(subject);
        msg.setSentDate(new Date());
        msg.setText(messageText);
     
        Transport.send(msg);
     
        out.println("Mail was sent to " + to);
        out.println(" from " + from);
        out.println(" using host " + host + ".");
     
    %>
        </table>
      </body>
    </html>


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: please any one help in this application ,this simple application can you send mes

    but found some problem I can't solve it
    What problem? You need to be more specific about the nature of the problem - exceptions, stack traces, etc...

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    11
    My Mood
    Relaxed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please any one help in this application ,this simple application can you send mes

    mention the problems, that will be handy in solving them.
    and also put page attributes at the top of the file.

Similar Threads

  1. Replies: 2
    Last Post: March 3rd, 2011, 01:22 PM
  2. Replies: 1
    Last Post: January 12th, 2011, 04:55 AM
  3. [SOLVED] [help] the application file (.jad) for application does not appear to be the ....
    By ordinarypeople in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: April 4th, 2010, 03:50 AM
  4. how to send a message to receiver with if else statement
    By humdinger in forum Loops & Control Statements
    Replies: 10
    Last Post: December 4th, 2009, 09:56 AM
  5. Replies: 0
    Last Post: December 3rd, 2009, 03:43 PM