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 2 of 2

Thread: Re: sending email to outlook

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: sending email to outlook

    Hi All I am also suffering with same problem with Outlook Here i tried with this below code but i am not able to handle this
    Here i writtern some code for outlook. here getting "ImpaAddress" what i need to pass please help me on this

    import java.util.Properties;

    import javax.mail.Folder;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.Session;
    import javax.mail.Store;

    public class Readmail {

    public static void main(String[] args) throws MessagingException{


    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imaps");
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("<impap_address>","rajashekar09.pani kera@gmail.com", "rajashekarraju");

    Folder inbox = store.getFolder("Inbox");
    System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
    inbox.open(Folder.READ_ONLY);



    }
    }




    Getting errore like Exception in thread "main" javax.mail.MessagingException: <impap_address>;
    nested exception is:
    java.net.UnknownHostException: <impap_address>
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:670)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at testcases.Readmail.main(Readmail.java:20)
    Caused by: java.net.UnknownHostException: <impap_address>
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.mail.util.SocketFetcher.createSocket(Socke tFetcher.java:319)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFe tcher.java:233)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:113 )
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMA PProtocol.java:111)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:637)
    ... 3 more

    Hi All I want to read mail from outlook. I tried with some code but i am unable to get the protocol and host name. here how to get the port name, host name please help me on this provide some code regarding this..

    package testcases;

    import java.util.Properties;

    import javax.mail.Folder;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.Session;
    import javax.mail.Store;

    public class Readmail {

    public static void main(String[] args) throws MessagingException{


    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imaps");
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("imaps","rajashekar09.panikera@gmail .com", "rajashekarraju");

    Folder inbox = store.getFolder("Inbox");
    System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
    inbox.open(Folder.READ_ONLY);



    }
    }



    Getting error like :

    Exception in thread "main" javax.mail.MessagingException: imaps;
    nested exception is:
    java.net.UnknownHostException: imaps
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:670)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at testcases.Readmail.main(Readmail.java:20)
    Caused by: java.net.UnknownHostException: imaps
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.mail.util.SocketFetcher.createSocket(Socke tFetcher.java:319)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFe tcher.java:233)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:113 )
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMA PProtocol.java:111)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPSt ore.java:637)
    ... 3 more



    Thanks In Advance
    Hiral
    Last edited by copeg; November 4th, 2012 at 10:39 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: sending email to outlook

    Please don't hijack someone else's post. I have merged both of your posts into one

Similar Threads

  1. Java Code Send email from email id configured in outlook
    By Hrithik in forum Java Theory & Questions
    Replies: 0
    Last Post: September 21st, 2012, 02:41 AM
  2. Exception while sending Email.
    By hashitagarwal in forum Exceptions
    Replies: 1
    Last Post: September 13th, 2012, 12:50 AM
  3. sending email to outlook
    By cnjiru in forum Java Networking
    Replies: 2
    Last Post: July 31st, 2012, 09:05 AM
  4. Trouble sending an email from my program
    By java99 in forum Java Networking
    Replies: 5
    Last Post: January 11th, 2012, 11:22 PM
  5. Trouble sending an email from my program
    By java99 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 11th, 2012, 05:27 PM