javamail如何下载外网的附件(如163、yahoo、126之类)?? javamail如何下载外网的附件(如163、yahoo、126之类)??麻烦大家帮帮忙!!谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public void recieve() throws Exception{ String host = "220.181.12.114"; //【pop.mail.yahoo.com.cn】 String username ="stony"; //【wwp_1124】 String password ="123456"; //【........】 Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); Store store = session.getStore("pop3"); store.connect(host, username, password); Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_WRITE); Message message[] = folder.getMessages(); System.out.println("Messages's length: "+message.length); PraseMimeMessage pmm = null; String subject=""; String sender=""; boolean isnew=false; for(int i=0;i<message.length;i++){ try { pmm = new PraseMimeMessage((MimeMessage)message[i]); subject=pmm.getSubject(); String attachPath=pmm.getAttachPath(); File getfile=new File(attachPath); File myfile=new File("C:\\test"); if (getfile!=null){ FileInputStream input = new FileInputStream(getfile); FileOutputStream output = new FileOutputStream(myfile); byte[] b = new byte[1024 * 5]; int len; while ((len = input.read(b)) != -1) { output.write(b, 0, len); } output.flush(); output.close(); input.close(); } System.out.print(subject); String senddate=pmm.getSentDate(); sender=pmm.getFrom(); isnew=pmm.isNew(); System.out.print(isnew); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }试一下,有问题请说明。 如何去分析一个项目? JTable可以合并单元格吗? 到底swing用的是哪个包啊?这个问题好郁闷。 jscrollpane 定位 请教,如何把一个java程序转换成jar文件? 在Java中怎樣進行日期的加減? 救命啊!!!怎样让鼠标点击JTree上的Node时成为手形? 我想购买一个收费邮箱,请问哪个比较好?谢谢 怎么样去除浏览器中的滚动条,而采用内部的滚动条! 如何通过java收发邮件? 添加数据程序问题??高手请指点! 想學習SWT,但找不到資料.請大家給我一些.要電子書的.
String host = "220.181.12.114"; //【pop.mail.yahoo.com.cn】
String username ="stony"; //【wwp_1124】
String password ="123456"; //【........】 Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("pop3");
store.connect(host, username, password); Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
Message message[] = folder.getMessages();
System.out.println("Messages's length: "+message.length);
PraseMimeMessage pmm = null;
String subject="";
String sender="";
boolean isnew=false;
for(int i=0;i<message.length;i++){
try {
pmm = new PraseMimeMessage((MimeMessage)message[i]);
subject=pmm.getSubject();
String attachPath=pmm.getAttachPath();
File getfile=new File(attachPath);
File myfile=new File("C:\\test");
if (getfile!=null){
FileInputStream input = new FileInputStream(getfile);
FileOutputStream output = new FileOutputStream(myfile);
byte[] b = new byte[1024 * 5];
int len;
while ((len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
}
System.out.print(subject);
String senddate=pmm.getSentDate();
sender=pmm.getFrom();
isnew=pmm.isNew();
System.out.print(isnew);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
试一下,有问题请说明。