问题描述
public class NetManager extends Thread {
public Multipart mp;
public String host,username,password;
public NetManager(String username,String password)
{
this.host = "imap.gmail.com";
this.username = username;
this.password = password;
}
private Session getImapSession() {
Properties props = new Properties();
props.setProperty("mail.store.protocol","imap");
props.setProperty("mail.debug","false");
props.setProperty("mail.imap.host","imap.gmail.com");
props.setProperty("mail.imap.port","993");
props.setProperty("mail.imap.ssl.enable","true");
Session session = Session.getDefaultInstance(props,null);
session.setDebug(true);
return session;
}
public Folder getMailBox()
{
try
{
Session currentSession = getImapSession();
Store store = currentSession.getStore("imap");
store.connect(host,password);
IMAPFolder inBox = (IMAPFolder)store.getFolder("INBox");
inBox.open(Folder.READ_ONLY);
return inBox;
}
catch (Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public void run() {
super.run();
Folder inBox = getMailBox();
try {
int counter = 0;
Message[] messg = inBox.getMessages();
for (int i = 0; i < messg.length; i++)
{
if(messg[i].getSubject().equals("check"))
{
mp = (Multipart) messg[i].getContent();
}
}
} catch (MessagingException | IOException e) {
System.out.println("Error");
}
}
解决方法
int a=JoptionPane.show..
应该是:
int a=JOptionPane.show..
Java 区分大小写,选项窗格的第一个 'o' 是大写的 'O'。