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