Need Java Mail help

good evening everybody
iam new to JavaMail
i used an example from oracle site that uses JavaMail to send an email, the applications tells me that the email has been sent successfully, but sadly i did't find any new emails in the email inbox i sent to......... i don't know the reasone...........
the second thing is . is it important to write the password of the email i want to send from ????
the last thing, what is the mail server i have to put when i use hotmail for example ........
thanks
and here is the code
package myClasses;
import javax.mail.*;          //JavaMail packages
import javax.mail.internet.*; //JavaMail Internet packages
import java.util.*;           //Java Util packages
public class SendMailBean {
  public String send(String p_from, String p_to, String p_cc, String p_bcc,String p_subject, String p_message, String p_smtpServer) {
    String l_result = "<BR><BR><BR><BR><BR><BR><BR>";
    // Name of the Host machine where the SMTP server is running
    String l_host = p_smtpServer;
    // Gets the System properties
    Properties l_props = System.getProperties();
    // Puts the SMTP server name to properties object
    l_props.put("mail.smtp.host", l_host);
    // Get the default Session using Properties Object
    Session l_session = Session.getDefaultInstance(l_props, null);
    l_session.setDebug(true); // Enable the debug mode
    try {
      MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
      l_msg.setFrom(new InternetAddress(p_from)); // Set the From address
      // Setting the "To recipients" addresses
      l_msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(p_to, false));
      // Setting the "Cc recipients" addresses
      l_msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(p_cc, false));
      // Setting the "BCc recipients" addresses
      l_msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(p_bcc, false));
      l_msg.setSubject(p_subject); // Sets the Subject
      // Create and fill the first message part
      MimeBodyPart l_mbp = new MimeBodyPart();
      l_mbp.setText(p_message);
      // Create the Multipart and its parts to it
      Multipart l_mp = new MimeMultipart();
      l_mp.addBodyPart(l_mbp);
      // Add the Multipart to the message
      l_msg.setContent(l_mp);
      // Set the Date: header
      l_msg.setSentDate(new Date());
      // Send the message
      Transport.send(l_msg);
      // If here, then message is successfully sent.
      // Display Success message
      l_result = l_result + "<FONT SIZE=4 COLOR=\"blue\"><B>Success!</B>"+
                 "<FONT SIZE=4 COLOR=\"black\"> "+
                 "<HR><FONT color=green><B>Mail was successfully sent to </B></FONT>: "+p_to+"<BR>";
      //if CCed then, add html for displaying info
      if (!p_cc.equals(""))
        l_result = l_result +"<FONT color=green><B>CCed To </B></FONT>: "+p_cc+"<BR>";
      //if BCCed then, add html for displaying info
      if (!p_bcc.equals(""))
        l_result = l_result +"<FONT color=green><B>BCCed To </B></FONT>: "+p_bcc ;
      l_result = l_result+"<BR><HR>";
    } catch (MessagingException mex) { // Trap the MessagingException Error
        // If here, then error in sending Mail. Display Error message.
        l_result = l_result + "<FONT SIZE=4 COLOR=\"blue\"> <B>Error : </B><BR><HR> "+
                   "<FONT SIZE=3 COLOR=\"black\">"+mex.toString()+"<BR><HR>";
    } catch (Exception e) {
        // If here, then error in sending Mail. Display Error message.
        l_result = l_result + "<FONT SIZE=4 COLOR=\"blue\"> <B>Error : </B><BR><HR> "+
                   "<FONT SIZE=3 COLOR=\"black\">"+e.toString()+"<BR><HR>";
        e.printStackTrace();
    }//end catch block
    finally {
      return l_result;
  } // end of method send
} //end of bean

good evening everybody
iam new to JavaMailDon't forget to read the JavaMail FAQ!
i used an example from oracle site that uses JavaMail
to send an email, the applications tells me that the
email has been sent successfully, but sadly i did't
find any new emails in the email inbox i sent
to......... i don't know the reasone...........Turn on session debugging and examine the protocol
trace. It might provide some clues. If it still seems like
the server is accepting the message without complaint,
the problem is in your mail server, or perhaps in any filters
you have on your incoming mail. Check the mail server
log file for clues.
the second thing is . is it important to write the
password of the email i want to send from ????Maybe. It depends on whether your mail server requires
authentication or not.
the last thing, what is the mail server i have to put
when i use hotmail for example ........I don't know, check the hotmail web site for information
about how to configure your mail client. Last time I looked,
hotmail didn't even support such usage.

Similar Messages

  • Have installed Mountain Lion and need Java. Help

    Hi,
    I installed Mountain Lion this past week.
    I am subscribed to two games sites. They both require me to have Java to use them.
    I read after I installed ML that there is no Java in this. However, I guess I still had the Apple Java from Snow Leopard.
    But, I thought I had to install Java 7 (think at some point I was asked to update Java and it took me to that.
    I then read that Chrome can't use the Java I had installed.
    So I then tried to use Safari.
    Then I picked up FireFox again. I used to have FireFox but had not used it in a while.
    Finally managed to get FireFox to run the one site. Quadplex.
    However nothing would allow me to use Pogo. I can get to the main page on Pogo, but when I try to activate the games there, it sits and loads and loads and eventually as it SHOULD open it just up and disappears!
    Eventually in some of my searching, I read that Java 7 is not secure. That there is a security issue in it.
    I searched until I found where I could uninstall Java 7. And I did that. Then I clicked on the link that said I could install the Apple Java that I had managed to get rid of originally (well I assume it is gone since even after a restart, Safari does not let me play anything requiring Java.
    I tried to reinstall the Apple Java and got to what I had read was the "terminal". I began to try the commands that were posted on the Apple support page I was on, but it asked for an Administrator Password. To my knowledge I have never had that on my Mac. I usually just click where the window pops up to ask for it and that window goes away and I can install anything without entering any password. But in the "terminal" I tried to just click on the return to go to the next step in the commands routine and it would not allow me to continue.
    I am on a MacPro 15" purchased in August 2009 and which has been refurbished due to me having spilled a drink all over the keys area of it in November of 2010. It has been working great until I went ahead and installed Mountain Lion and now have removed the Java download as I read it is not secure and can expose Mac users to something refered to as "drive by" viruses.
    I am really at a loss here. The tech I would normally go to may or may not be available this week and I really am frustrated by missing out on my daily gaming.
    Any one here who can help with my problem?
    Thanks, Carine (aka catonwheels)

    Thanks Baltwo...and yes it did...by the time I got your response (and it was great that you sent it!) I had already FINALLY found that I needed 7u11 and then found THAT! I had tried to find it after reading about it somewhere during my surfing for a solution but couldn't seem to find it and then when I clicked on an update link SOMEWHERE I was taken right to it. I remembered that the original Java I had downloaded did not have 11 in it and so I downloaded the one that was at that link where I was taken and voila! It worked...however, had I NOT found it having you respond to my help plea would have fixed it and I thank you for taking the time. I had gone to Oracle originally to find this update but somehow I did not get it the first time round. So this would have been great had I not fallen over it when I did. Again, thank you and now at least I am in this community and will have a lot of support and info when I need it! :-)

  • Need Safari Mail Help

    More help needed.
    I always keep my address book up to date and have to change an email address or two. HOWEVER, when I go to compose/send an email and I type in the person's name as the email recipient and Safari Mail gives me the choice of the old email address (which is now useless and annoying) and the new email address which is needed. How do I get rid of the old email address from popping up as a choice?
    I have gone into Safari Mail Preferences-Composing and unchecked "Automatically Complete Address" then logged off as user. I have even "restart" Leopard. I then go and "recheck" "Automatically Complete Address" and still get the old email addresses as options EVEN THOUGH I have removed these email addresses from my address book. How must I correct this?
    Thanks.

    Mail for OS X Leopard
    http://discussions.apple.com/forum.jspa?forumID=1223
    http://www.apple.com/support/leopard/mail/
    Have you looked for a cache file?
    Leopard has a real mess of spagetti string of aliases, links, and to me a real mess in
    ~/Library/Application Support/SyncServices
    all related to push technology and synchronizing with phones and cloud services.

  • Need Java code Help

    Hi All,
    I need your hlep...
    I have a javamapping where it should read the webservice response and transform into the target structure..
    Webservice response is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MT_WS_Response xmlns:ns1="http://RFC_Lookup/XI">
    <row>
    <ID>001</ID>
    <KEY>Matnr</KEY>
    <VALUE>34567</VALUE>
    </row>
    <row>
    <ID>002</ID>
    <KEY>Matnr</KEY>
    <VALUE>34567</VALUE>
    </row>
    <row>
    <ID>003</ID>
    <KEY>Matn33</KEY>
    <VALUE>34567</VALUE>
    </row>
    </ns1:MT_WS_Response>
    I should read the above structure and output it into a payload string variable ...
    i have declared variables also
    public void execute(InputStream in, OutputStream out)
              try
                   trace.addInfo("Start of Extraction");
                   OutputStream temp = new ByteArrayOutputStream(1024);
                   byte[] buffer = new byte[1024];
                    for (int read = in.read(buffer); read > 0; read = in.read(buffer))
                         temp.write(buffer, 0, read);
                   String Payload = temp.toString();
                   final String STARTTAG = "<row>";
                   final String ENDTAG = "</row>";
                   int Y_FILENAME_START  = Payload.indexOf(STARTTAG);
                   int Y_FILENAME_END = Payload.indexOf(ENDTAG);
                   int spos = Y_FILENAME_START+STARTTAG.length();
                   <b>if ( ( Y_FILENAME_END > spos) && (Y_FILENAME_END > 0 ) )</b>               {
                        Payload = Payload.substring(Y_FILENAME_START+STARTTAG.length() , Y_FILENAME_END);
                        trace.addInfo("Sucessfully Extracted");
    Please suggest whether how can i read multiple rows .. as i am ABAPER i am unable to do it in Java..
    I think the bold one reads only single row ... please suggest for reading multiple rows...
    Thanks and Regards,
    sridhar reddy
    Message was edited by:
            sridhar reddy kondam

    Please tell us what is the expected target structure.
    Also, avoid to treat xml like strings. Use parsing methods (SAX, DOM). It is way easier, and they are mainly the reason why you should use java mappings over ABAP mappings.
    Regards,
    Henrique.

  • Beginner needs Java applet Help!!!

    I would be greatful if someone could answer any of the questions below following the description, thank you:
    Description:
    There are 3 textFields, 3buttons(add,delete,display), and 1 textArea on my applet.
    User types their "name" in the first textField(called tField1)
    User types their "surnname" in the second textField(called tField2)
    User Types their "Town" in the Third textField(called tField3)
    User presses add button to add details to an array of type "member".
    User presses display to view all members(elements of the array) in the TextArea.
    User adds details to textFields and presses the delete button to delete that member.
    member.class:
    Has constructors, individual set and get methods and private attributes name,surname + address plus a toString method.
    Code Behind the ADD button i.e. in the VOID ADD_ACTIONTIONPERFORMED(ACTION EVENT) method:
    Q1.How do i create an array of type member?
    Is it: MEMBER X[] = NEW MEMBER[100]; If so Where does this statement go?
    Q2.How do i allow the user to keep adding more members every time the add button is pressed?
    Code Behind the DISPLAY button i.e. in the VOID DISPLAY_ACTIONTIONPERFORMED(ACTION EVENT) method:
    Q3. How do i get member array elements displayed into the Textfield?
    Code Behind the DELETE button i.e. in the VOID DELETE_ACTIONTIONPERFORMED(ACTION EVENT) method:
    Q4. Deleting user selected elements?
    thanks for your time

    Q1.How do i create an array of type member?
    Is it: MEMBER X[] = NEW MEMBER[100]; Not unless MEMBER is final, which would be inappropriate here + I'd advise the word 'new' though not 'NEW'.
    If so Where does this statement go?In your source code file
    Q2.How do i allow the user to keep adding more members
    every time the add button is pressed?By having source code that creates the conditions for this
    >
    Code Behind the DISPLAY button i.e. in the VOID
    DISPLAY_ACTIONTIONPERFORMED(ACTION EVENT) method:Again these are not final methods, they are overrided methods
    Q3. How do i get member array elements displayed into
    the Textfield?This goes back to the thorny issue of writing code again. It's generally quite hard to do this sort of thing without it.
    >
    Code Behind the DELETE button i.e. in the VOID
    DELETE_ACTIONTIONPERFORMED(ACTION EVENT) method:Again, this is overriden, so final declarations are not permitted
    Q4. Deleting user selected elements?See above, re: source code.
    thanks for your time Welcome, we're here to help

  • Sending mails - help needed

    hi, i need some help for java mail, as i am a starter i would like to know few questions:
    I use internet connection from a local ISP with whom i do not have email signup, nor i know their mail server details or name, but i would like to send mail to a account on hotmail or yahoo but i don't know their email server info either, so what i should do?
    can you please explain in detail
    warm regards
    mustafa
    hyderabad
    india

    Hi,
    I use internet connection from a local ISP with whom i
    do not have email signup, nor i know their mail server
    details or name, but i would like to send mail to a
    account on hotmail or yahoo but i don't know their email
    server info either, so what i should do?You can use softwares like PostCast Server(www.postcastserver.com/)
    which is a free SMTP mail server program which enables you to send
    e-mail directly from your computer, without your Internet Service Provider's server.
    Other way, you can make use of free SMTP servers (a list of free
    SMTP servers is available at http://www.thebestfree.net/free/freesmtp.htm) to send mails.
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

  • Help me IN JAVA MAIL

    HI TO ALL......
    I AM NEW TO THIS FIELD....I AM TRYING TO SEND EMAIL THROUGH JAVA MAIL FUNCTION......,FIRST I AM FETCHING THE MAIL ADDRESS FROM DATA BASE.....I WANT TO SEND MAIL TO THOSE ADDRESS......HERE I M LITTLE BIT CONFUSED....PLZ HELP ME....BELOW IS THE CODE.........
    THIS FOR SEARCHING THE MAIL IDS......(SearchEmail .java)
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class SearchEmail extends HttpServlet {
    public String s1;
    public String username="root";
    public String passWord="";
    public String url="jdbc:mysql://192.168.0.7:3306/ias";
    private String SUB_NO="";
    private String ST_DT="";
    private String EMAIL="";
    public void init() {
    try {
    Class.forName("sun.mysql.Jdbc.Driver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    /**Process the HTTP Get request*/
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    sendPageHeader(response);
    sendSearchForm(response);
    sendPageFooter(response);
    /**Process the HTTP Post request*/
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ST_DT = request.getParameter("ST_DT");
    sendPageHeader(response);
    sendSearchForm(response);
    sendSearchResult(response);
    sendPageFooter(response);
    public void sendSearchResult(HttpServletResponse response)
    throws IOException {
    PrintWriter out = response.getWriter();
    try {
    Connection con = DriverManager.getConnection(url,username,passWord);
    System.out.println("got connection");
    Statement s = con.createStatement();
    String sql= "SELECT EMAIL " + "FROM temp "+
    "WHERE ST_DT='" + ST_DT + "' AND EMAIL!='" + null + "'";
    ResultSet rs = s.executeQuery(sql);
    StringBuffer sb = new StringBuffer(100);
    while (rs.next()) {
    String SUB_NO = rs.getString(1);
    s1 =sb.append( rs.getString(1)).append(",").toString();
    out.println("<TABLE border='1'>");
    out.println("<TR>");
    out.println("<TD>TO</TD><TD><INPUT TYPE=TEXT SIZE='50' VALUE='"+ s1 +"' ></TD>");
    out.println("</TR>");
    out.println("<TR>");
    out.println("<TD>FROM</TD><TD><INPUT TYPE=TEXT SIZE='50' [email protected] ></TD>");
    out.println("</TR>");
    out.println("</TR>");
    out.println("<TD>SUBJECT</TD><TD><INPUT TYPE=TEXT SIZE='50' NAME=SUBJECT></TD>");
    out.println("</TR>");
    out.println("<TR>");
    out.println("<TD>MESSAGE </TD><td><textarea cols='70' rows='20' name='MESSAGE'>");
    out.println("C.Vedamurthy senior");
    out.println("Administrative Assistant");
    out.println("Indian Academy of Sciences");
    out.println("C.V.Raman Avenue,Near Mekhri Circle");
    out.println("Post Box No 8005,sadashivanagar'");
    out.println("bangalore 560080");
    out.println("office no 23612546,23611034,23612943 extn 207 ");
    out.println("res 23431357;Fax 23616094;");
    out.println("</textarea></td>");
    out.println("</TR>");
    out.println("<table align='center'>");
    out.println("<TR>");
    out.println("<form action='mailservlet' method='post' name='myform'>");
    out.println("<CENTER> <TD><INPUT TYPE='SUBMIT' VALUE='send'></INPUT></TD></CENTER>");
    out.println("</form>");
    out.println("</TR>");
    out.println("</TABLE>");
    rs.close();
    s.close();
    con.close();
    catch (SQLException e) {
    catch (Exception e) {
    out.println("</TABLE>");
    * Send the HTML page header, including the title
    * and the <BODY> tag
    private void sendPageHeader(HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>Displaying Selected Record(s)</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY BGCOLOR=#FFE4C4>");
    out.println("<CENTER>");
    * Send the HTML page footer, i.e. the </BODY>
    * and the </HTML>
    private void sendPageFooter(HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("</CENTER>");
    out.println("</BODY>");
    out.println("</HTML>");
    /**Send the form where the user can type in
    * the details for a new user
    private void sendSearchForm(HttpServletResponse response)
    throws IOException {
    PrintWriter out = response.getWriter();
    out.println("<BR><H2>Search</H2>");
    out.println("<BR>");
    out.println("<BR><FORM METHOD=POST>");
    out.print("START DATE: <INPUT TYPE=TEXT Name=ST_DT");
    out.print(" VALUE=\"" + ST_DT + "\"");
    out.println(">");
    out.println("<BOTTOM>");
    out.println("<TABLE ALIGN='CENTER'>");
    out.println("<INPUT TYPE=SUBMIT VALUE=submit>");
    out.println("</TABLE>");
    out.println("</FORM>");
    THIS IS JAVA MAIL FUNCTION.........(mailservlet .java)
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*; // important
    import javax.mail.event.*; // important
    import java.net.*;
    import java.util.*;
    import javax.mail.MessagingException;
    public class mailservlet extends HttpServlet
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    PrintWriter out=response.getWriter();
    response.setContentType("text/html");
    try
    Properties props=new Properties();
    props.put("mail.smtp.host","localhost"); // 'localhost' for testing
    Session session1 = Session.getDefaultInstance(props,null);
    String s1 = request.getParameter("FROM"); //sender (from)
    String s2 = request.getParameter("EMAIL");
    String s3 = request.getParameter("SUBJECT");
    String s4 = request.getParameter("MESSAGE");
    Message message =new MimeMessage(session1);
    message.setFrom(new InternetAddress(s1));
    message.setRecipients
    (Message.RecipientType.TO,InternetAddress.parse(s2,false));
    message.setSubject(s3);
    message.setText(s4);
    Transport.send(message);
    out.println("mail has been sent");
    catch(Exception ex)
    out.println("COULD NOT SEND EMAIL.....");
    plz help me its very urgent ........

    out.println("<TD>TO</TD><TD><INPUT TYPE=TEXT SIZE='50' VALUE='"+ s1 +"' ></TD>");
    out.println("</TR>");
    out.println("<TR>");
    out.println("<TD>FROM</TD><TD><INPUT TYPE=TEXT SIZE='50' VALUE=[email protected] ></TD>");
    You didn't put names to those fields above:
    out.println("<TD>TO</TD><TD><INPUT TYPE=TEXT SIZE='50' VALUE='"+ s1 +"' name ='EMAIL'></TD>");
    out.println("</TR>");
    out.println("<TR>");
    out.println("<TD>FROM</TD><TD><INPUT TYPE=TEXT SIZE='50' VALUE='[email protected]'  name='FROM'></TD>");also try:
    catch(Exception ex)
    out.println("COULD NOT SEND EMAIL.....");
    ex.printStackTrace();
    }to know what is exactly the error.

  • In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    Go to System prefs
    Select Mail Contacts and Calendars
    Then select Other
    Then select "Add a Mail Account and click create
    Then go to google for the settings you need:
    First here for the settings online at gmail http://tinyurl.com/du3fu
    Then here for the setting in mail http://tinyurl.com/38fevm8
    These are instructions for Mail 4.0 but all of the necessary settings should be listed.

  • Can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    Java is no longer included in Mac OS X by default. If you want Java, you will have to install it.
    However, note that you should think twice before installing Java for such a trivial need as looking at stock market quotes. There are other ways to get that information that don't involve Java, and using Java in your web browser is a HUGE security risk right now. Java has been vulnerable to attack almost constantly for the last year, and has become a very popular, frequently used method for getting malware installed via "drive-by downloads." You really, truly don't want to be using it. See:
    Java is vulnerable… Again?!
    http://java-0day.com

  • Java Mail set up HELP

    I am trying to set up Java Mail, but am totally lost.
    I have no clue where i edit CLASSPATH, to let me use the mail api, i also read that i needed Java beans activation Network, but that is included in the most recent JDK update which i have.
    If i could just get a step by step on where to edit this that would be great.

    I don't know what JBA is.
    README.txt says:
      1. Unzip the javamail-1_4_1.zip archive. (you may have already done this)
      2. Set your CLASSPATH to include the "mail.jar" file obtained from
         the download, as well as the current directory.
         Assuming you unzipped javamail-1_4_1.zip in c:\download the
         following would work:
          set CLASSPATH=%CLASSPATH%;c:\download\javamail-1.4.1\mail.jar;.
        Also include the "activation.jar" file that you obtained from
        downloading the JavaBeans Activation Framework, in your CLASSPATH.
          set CLASSPATH=%CLASSPATH%;c:\download\activation\activation.jarWhich part of that was confusing?
    Yes, you can download it anywhere and unzip it
    anywhere, but wherever you put it, that's the
    path you have to use when you set CLASSPATH.
    Do you understand?
    Likewise, you have to download the JavaBeans
    Activation Framework, unzip the zip file (anywhere)
    and use the correct path name when setting
    CLASSPATH.
    If it's still not working for you, tell me exactly what
    you did and exactly what happened. Copy and
    paste the text from the command window if possible.

  • HT5675 i need java 1.6 to get ,m,inecraft but it wont ever work please help?

    i need java 1.6 to get minecraft but it wont ever work someone please help me!

    Hello,
    What version of Mac OS X are you running on your iBook?
    Also check what version of java is currently installed by doing the following,
    Open Terminal, type in java -version then press Enter.  Then retrieve the current java version, in this example being 1.6.0_24

  • Help for java mail

    i want devloped java mail , what should i do

    Everything you need is on the JavaMail web page, which was referred to
    in the header to this forum. Did you see it?
    http://java.sun.com/products/javamail

  • Java Mail Project HELP Required....URGENT PLZ HELP!!!

    hello there!!
    i took up a pjct for my engineering on java mail..got the code..and i thought that ill analyse it...the code is submitting the mail to the smtp server but after dat its failing to deliver to the client..as i can see this error in the logs on SMTP server...can anyone help me out in analysing this code!!!
    plz help, exams are near...(am new to java)
    //java FINAL!
    import javax.swing.*;
    import java.net.URL;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EmailProg extends JPanel implements ActionListener {
    protected JTextArea textArea;
    protected String newline = "\n";
    static final private String composemail = "compose";
    static final private String sendmail = "send";
    static final private String about = "about";
    static final private String submit = "submit";
    static final private String exit = "exit";
    JLabel lSubmit = new JLabel("Submit");
    JButton subbutton = new JButton();
    JTextArea emailfrom = new JTextArea(1,1);
    JTextArea emailto = new JTextArea(1, 1);
    JTextArea emailsubject = new JTextArea(1, 1);
    JTextArea emailmessage = new JTextArea(25, 1);
    //------BAG LAYOUT
    JLabel lFrom = new JLabel("From:");
    JTextField cFrom = new JTextField(32);
    JLabel lTo = new JLabel("To:");
    JTextField cTo = new JTextField(32);
    JFrame frame2 = new JFrame("Compose New");
    JLabel lSubject = new JLabel("Subject");
    JTextField cSubject = new JTextField(32);
    JLabel lMessage = new JLabel("Body");
    JTextArea cMessage = new JTextArea(5,32);
    //====================================
    public EmailProg() {
    super(new BorderLayout());
    //Create the toolbar.
    JToolBar toolBar = new JToolBar();
    addButtons(toolBar);
    //Create the text area used for output. Request
    //enough space for 5 rows and 30 columns.
    textArea = new JTextArea(5, 30);
    textArea.setEditable(false);
    textArea.setText("Welcome to Jeff's email program! With this program you can compose and send emails. I hope I get a good grade on thise, and marine world finds a good use for it :-D:-D (implements really just testing the scroller!!!)");
    JScrollPane scrollPane = new JScrollPane(textArea);
    //Lay out the main panel.
    setPreferredSize(new Dimension(450, 110));
    add(toolBar, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    //==================================
    protected void addButtons(JToolBar toolBar) {
    JButton button = null;
    //first button
    button = makeNavigationButton("/toolbarButtonGraphics/general/ComposeMail24.gif", composemail ,"Compose new Email", "compose new");
    toolBar.add(button);
    //second button
    button = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", sendmail,"Send The Mail","send");
    toolBar.add(button);
    //third button
    button = makeNavigationButton("toolbarButtonGraphics/general/About24.gif", about,"About","About");
    toolBar.add(button);
    //exit button
    button = makeNavigationButton("toolbarButtonGraphics/general/Stop24.gif", exit, "Exit", "Exit");
    toolBar.add(button);
    //===================================
    protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
    //Look for the image.
    String imgLocation = imageName;
    URL imageURL = EmailProg.class.getResource(imgLocation);
    //Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);
    if (imageURL != null) {                      //image found
    button.setIcon(new ImageIcon(imageURL));
    } else {                                     //no image found
    button.setText(altText);
    System.err.println("Resource not found: "+ imgLocation);
    return button;
    //=============================
    public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    String description = null;
    // Handle each button.
    if (exit.equals(cmd)){
    textArea.setText("");
    description = "EXITING";
    System.exit(0);
    if (composemail.equals(cmd)) { //first button clicked
    textArea.setText("");
    description = "Write new mail.";
    composeWindow();
    } else if (sendmail.equals(cmd)) { // second button clicked
    textArea.setText("");
    description = "This button does'nt do anything yet :x";
    } else if (about.equals(cmd)) { // third button clicked
    textArea.setText("");
    description = "About this program. (See pop-up)";
    coolWindow();
    else if (submit.equals(cmd))
    if (cFrom.getText().equals("")||cTo.getText().equals("")||cSubject.getText().equals("")||cMessage.getText().equals(""))
    textArea.setText("One or more of the fields was not filled in.");
    else{
    try {
    String smtpServer="serverhere";
    String to=cTo.getText();
    String from=cFrom.getText();
    String subject=cSubject.getText();
    String body=cMessage.getText();
    send(smtpServer, to, from, subject, body);
    textArea.setText("");
    description = "Mail Sent.";
    JOptionPane.showMessageDialog(null, "Message Sent.");
    catch (Exception ex)
    System.out.println("Usage: java com.lotontech.mail.SimpleSender"
    +" smtpServer toAddress fromAddress subjectText bodyText");
    //CLOSE THE FRAME2 WINDOW IIIIIIIIFFFFFFF SENDING IS SUCCESSFUL!!
    }//end of else during send
    }//end of if of submit
    displayResult(description);
    //============================
    protected void displayResult(String actionDescription) {
    textArea.append(actionDescription + newline);
    //=============================
    public void coolWindow() {
    JFrame frame = new JFrame("About");
    JTextArea filecontents = new JTextArea();
    filecontents.setText("Use the tool bar to compose\n compose new emails, in which you can\n send to anyone on the\n srvhs email server. \n Fill in all the blanks before pressing send. If you dont\n you will receive an error! \n For more information about this program click on the\n information button.");
    frame.getContentPane().add(filecontents, BorderLayout.CENTER);
    frame.pack();
    frame.setResizable(false);
    frame.setSize(300,200);
    frame.setVisible(true);
    //===============================
    public void composeWindow() {
    frame2.getContentPane().setLayout(new GridBagLayout());
    frame2.setResizable(false);
    frame2.setSize(600,500);
    frame2.setVisible(true);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 10, 5, 10);
    cMessage.setLineWrap(true);
    subbutton = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", submit,"submit","submit");
    addRow(gbc, lFrom, cFrom);
    addRow(gbc, lTo, cTo);
    addRow(gbc, lSubject, cSubject);
    addRow(gbc, lMessage, cMessage);
    addRow(gbc, lSubmit, subbutton);
    //===============================
    private void addRow(GridBagConstraints gbc, Component left, Component right) {
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = GridBagConstraints.RELATIVE;
    gbc.gridheight = 1;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.EAST;
    frame2.getContentPane().add(left, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    frame2.getContentPane().add(right, gbc);
    frame2.pack();
    //=======================
    public static void send(String smtpServer, String to, String from, String subject, String body) {
    try {
    Properties props = System.getProperties();
    props.put("localhost", smtpServer);
    Session session = Session.getDefaultInstance(props, null);
    System.out.println(smtpServer);
    // -- Create a new message --
    Message msg = new MimeMessage(session);
    // -- Set the FROM and TO fields --
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
    // -- We could include CC recipients too --
    // if (cc != null)
    // msg.setRecipients(Message.RecipientType.CC
    // ,InternetAddress.parse(cc, false));
    // -- Set the subject and body text --
    msg.setSubject(subject);
    msg.setText(body);
    // -- Set some other header information --
    msg.setHeader("X-Mailer", "LOTONtechEmail");
    msg.setSentDate(new Date());
    // -- Send the message --
    Transport.send(msg);
    System.out.println("Message sent OK.");
    catch (Exception ex)
    ex.printStackTrace();
    public static void main(String[] args) {
    JFrame frame = new JFrame("EmailProg");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    EmailProg newContentPane = new EmailProg();
    newContentPane.setOpaque(true);
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    }

    The code to retrieve the messages from SMTP
    finally all working fine...
    thanx guys!!!
    package EmailProg;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
      * A simple email receiver class.
    public class SimpleReceiver
        * Main method to receive messages from the mail server specified
        * as command line arguments.
      public static void main(String args[])
        try
          String popServer=args[0];
          String popUser=args[1];
          String popPassword=args[2];
          receive(popServer, popUser, popPassword);
        catch (Exception ex)
          System.out.println("Usage: java com.mail.SimpleReceiver" +" popServer popUser popPassword");
        System.exit(0);
         * "receive" method to fetch messages and process them.
       public static void receive(String popServer, String popUser, String popPassword)
         Store store=null;
         Folder folder=null;
         try
           // -- Get hold of the default session --
           Properties props = System.getProperties();
           Session session = Session.getDefaultInstance(props, null);
           // -- Get hold of a POP3 message store, and connect to it --
           store = session.getStore("pop3");
           store.connect(popServer, popUser, popPassword);
           // -- Try to get hold of the default folder --
           folder = store.getDefaultFolder();
           if (folder == null) throw new Exception("No default folder");
           // -- ...and its INBOX --
           folder = folder.getFolder("INBOX");
           if (folder == null) throw new Exception("No POP3 INBOX");
           // -- Open the folder for read only --
           folder.open(Folder.READ_ONLY);
           // -- Get the message wrappers and process them --
           Message[] msgs = folder.getMessages();
           for (int msgNum = 0; msgNum < msgs.length; msgNum++)
             System.out.println(msgs[msgNum]);
         catch (Exception ex)
           ex.printStackTrace();
         finally
           // -- Close down nicely --
           try
             if (folder!=null) folder.close(false);
             if (store!=null) store.close();
           catch (Exception ex2) {ex2.printStackTrace();
      }

  • Java Mail,SMTP server not starting,help required urgently

    Hi i have been working on java mail .Yesterday it was working ok but today suddenely i am getting this thing.its not starting the smtp server i guess,just exiting and get the command prompt ..dont know what to do.help required how to go about this error
    am pasting the debug information.please check and let me know
    the compilation ,smtp server and others are all valid
    thanks
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Pavan>cd C:\Program Files\Java\jdk1.5.0_07\bin
    C:\Program Files\Java\jdk1.5.0_07\bin>javac jdbcExample3.java
    C:\Program Files\Java\jdk1.5.0_07\bin>java jdbcExample3 smtpserver address
    DEBUG: JavaMail version 1.4ea
    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_07\jre\lib\
    javamail.providers (The system cannot find the file specified)
    DEBUG: !anyLoaded
    DEBUG: not loading resource: /META-INF/javamail.providers
    DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
    DEBUG: Tables of loaded providers
    DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax
    .mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsyste
    ms, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com
    .sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLSt
    ore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
    ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.su
    n.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=jav
    ax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],
    com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP
    3Store,Sun Microsystems, Inc]}
    DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.
    sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STOR
    E,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Prov
    ider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc],
    pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
    , Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
    Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.S
    MTPTransport,Sun Microsystems, Inc]}
    DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
    DEBUG: !anyLoaded
    DEBUG: not loading resource: /META-INF/javamail.address.map
    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_07\jre\lib\
    javamail.address.map (The system cannot find the file specified)
    C:\Program Files\Java\jdk1.5.0_07\bin>

    The debug output doesn't show an obvious problem. You're
    going to have to actually debug your program. A debugger
    might be helpful.

  • Urgent help on java mail

    Hi,
    I have one prob with java mail .. How do i display file content in email ...
    When i pass content as String(suppose hello) it displays hello in email ....How do i display file content in html form when user opens his email .....
    Any help on this i will appriciate ..........
    Thanks.

    Hi,
    I have one jsp file and this file includes some include files ......
    How do i send this jsp file as body of email using java mail ................
    I did this by hot coding the tags and content ... i have to read from jps file and this file include some images ...........
    Here is my code ... Please can any one help me ....
    import java.io.*;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.activation.*;
    import javax.mail.internet.*;
    public class sendhtml {
    public static void sendMess(String[] argv) {
    String to, subject = "hello", from = null,
    cc = null, bcc = null, url = null;
    String mailhost = "xx.xxx.xx.xx";
    String mailer = "sendhtml";
    String protocol = null, host = null, user = null, password = null;
    String record = null; // name of folder in which to record mail
    boolean debug = false;
    try {  
    to="[email protected]";
    Properties props = System.getProperties();
    // could use Session.getTransport() and Transport.connect()
    // assume we're using SMTP
    if (mailhost != null)
    props.put("mail.smtp.host", mailhost);
    // Get a Session object
    Session session = Session.getDefaultInstance(props, null);
    if (debug)
    session.setDebug(true);
    // construct the message
    Message msg = new MimeMessage(session);
    if (from != null)
    msg.setFrom(new InternetAddress(from));
    else
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(to, false));
    if (cc != null)
    msg.setRecipients(Message.RecipientType.CC,
    InternetAddress.parse(cc, false));
    if (bcc != null)
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(bcc, false));
    msg.setSubject(subject);
    MimeMultipart mp = new MimeMultipart();
    mp.setSubType("related");
    MimeBodyPart mbp1= new MimeBodyPart();
    String html =
    "<html>"+
    "<head><title></title></head>"+
    "<body>"+
    "<b> see the following jpg : it is a car! !!!!!</b><br>"+
    "<a href=a.jsp>hello</a><br>"+
    "<img src=cid:123 >"+
    "<IMG SRC=cid:23 ><br>"+
    "<b> end of jpg</b>"+
    "<table><tr><td>"+
    "Every couple days for the next four weeks, we will send you new"+
    "can successfully sell your home.<br><br></td></tr>"+
    "<tr><td>"+
    "<p class=\"letter\">"+
         "saleMail Topics are: <br><br>"+
         "<ol class=\"letter\">"+
    "<li><b>Advertising Your Home: Part 2</b></li>"+
    "<li><b> Possibilities</b></li>"+
         "<li><b>Where Do You Go From Here?</b></li>"+
    "</ol>"+
    "<br><br></p></td></tr></table>"+
    "</body>"+
    "</html>";
    mbp1.setContent(html,"text/html");
    MimeBodyPart mbp2 = new MimeBodyPart();
    FileDataSource fds = new FileDataSource("/usr/local/images/dualsign.gif");
    mbp2.setFileName(fds.getName());
    mbp2.setText("This is a beautiful car !");
    mbp2.setDataHandler(new DataHandler(fds));
    mbp2.setHeader("Content-ID","23");
    FileDataSource fds1 = new FileDataSource("/usr/local/images/logo.gif");
    mbp2.setFileName(fds1.getName());
    mbp2.setText("This is a beautiful car !");
    mbp2.setDataHandler(new DataHandler(fds1));
    mbp2.setHeader("Content-ID","123");
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    msg.setContent(mp);
    msg.setSentDate(new Date());
    Transport.send(msg);
    System.out.println(mp.getCount());
    System.out.println("\nMail was sent successfully.");
    } catch (Exception e) {
    e.printStackTrace();

Maybe you are looking for

  • Error while changing PO

    We are having a problem  After a PO is ordered, you come back and change the PO (Quantity, Account assignment or add a new line) The PO errors out with incorrect account assignemnt. Even if you delete a line on previously created PO we get same error

  • Where is the button to purchase apps in IOS 7?

    I'm able to access the app store, but there appears to be no button to purchase apps.

  • Change y-axis BACK to auto/ auto for max min

    I have a bar chart and the settings for my y-axis are 250/auto. I need it to revert back to auto/auto for max/min b/c one of my numbers is large and is shooting off the graph.

  • Host in forms 10g and execute shell script

    Hi! I have a little problem. When I transfer form to AS through SSH protocol I want to automatically generate form on AS wit h code: declare lv_server_dir vc2() := /folder1/folder2; lv_file_name vc2():= a.fmb; host(lv_server_dir||'/ftp_gen.sh '||lv_s

  • Java.lang.RuntimeException: Iterator 'BeanIterator' not found

    Hi i have iterator which am using in two diifirent class,when i use the iterator in my first class is ok but when i take the same iterator with same code to another class i get the error "after Iterator 'ocompanyofficerdetailsIterator' not found",AM