Results 1 to 6 of 6
  1. #1
    Bagzli is offline Member
    Join Date
    Feb 2011
    Posts
    63
    Rep Power
    0

    Default Java Mail - Need help

    Hi, I am trying to program my app to send an e-mail to a user containing his password. Here is the code I am using but for some reason it doesn't work. If you could please enlighten me on my errors.

    Java Code:
    Properties props = new Properties();
                    props.put("mail.smtp.host", "msn.com");
                    props.put("mail.from", "example@msn.com");
                    Session session = Session.getInstance(props, null);
                    
                    
                        MimeMessage msg = new MimeMessage(session);
                        msg.setFrom();
                        msg.setRecipients(Message.RecipientType.TO,
                                          "example2@msn.com");
                        msg.setSubject("JavaMail hello world example");
                        msg.setSentDate(new Date());
                        msg.setText("Hello, world!\n");
                        Transport.send(msg);

  2. #2
    Bagzli is offline Member
    Join Date
    Feb 2011
    Posts
    63
    Rep Power
    0

    Default Re: Java Mail - Need help

    anyone at all?

  3. #3
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default Re: Java Mail - Need help

    You forgot about port and do you have exceptions when you run this code?
    Skype: petrarsentev
    http://TrackStudio.com

  4. #4
    Bagzli is offline Member
    Join Date
    Feb 2011
    Posts
    63
    Rep Power
    0

    Default Re: Java Mail - Need help

    no exceptions or errors, except it doesn't work.

    what about

    Java Code:
    props.put("mail.smtp.host", "msn.com");
                    props.put("mail.from", "example@msn.com");
    how do i find correct info that goes here?

  5. #5
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default Re: Java Mail - Need help

    Can you show all code, because I have confuse how you run it.
    Skype: petrarsentev
    http://TrackStudio.com

  6. #6
    Bagzli is offline Member
    Join Date
    Feb 2011
    Posts
    63
    Rep Power
    0

    Default Re: Java Mail - Need help

    that is the whole code, basically i have a link and when i click it that code is run. What i want to do is send an e-mail to myself. Can you show me what I am doing wrong and what is the right way to do it?

Similar Threads

  1. send mail via java without java mail API
    By majidvadoostan in forum Networking
    Replies: 2
    Last Post: 04-26-2011, 10:30 PM
  2. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 06:37 AM
  3. Replies: 2
    Last Post: 07-25-2009, 10:36 AM
  4. Replies: 2
    Last Post: 06-04-2009, 02:42 PM
  5. Replies: 2
    Last Post: 05-05-2008, 07:01 AM

Posting Permissions

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