易截截图软件、单文件、免安装、纯绿色、仅160KB

java 收邮件 使用 mail包

import java.util.Properties;
import javax.mail.FetchProfile;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.InternetAddress;

public class ReceiveMail
{
public ReceiveMail(){}

public static void main(String[] args)
{
receive();
}

public static void receive()
{
try
{
Properties props = new Properties();
Session s = Session.getInstance(props);
Store store = s.getStore("pop3");

//对应改成自己的用户名和密码
store.connect("pop.sina.com", "userName", "******");

Folder folder = store.getFolder("Inbox");
folder.open(Folder.READ_WRITE);

FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
Message arraymessage[] = folder.getMessages();
folder.fetch(arraymessage, profile);

System.out.println("收件箱的邮件数:" + arraymessage.length);
for (int i = 0; i < arraymessage.length; i++)
{
//邮件发送者
String from = arraymessage[i].getfrom()[0].toString();
InternetAddress ia = new InternetAddress(from);

System.out.println("******" + i + "******");

System.out.println("from:" + ia.getPersonal() + '(' + ia.getAddress() + ')');

//邮件标题
System.out.println("Title:" + arraymessage[i].getSubject());

//邮件大小
System.out.println("Size:" + arraymessage[i].getSize(


相关文档:

Java NIO API详解

 
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......

java 苦与乐(草稿)

  选择了java,也就是选择了一条光明而坎坷的道路。说他光明是因为应用的地方日益广泛,全球有很大的开发群体在为之忙碌,开源项目应有尽有;说他坎坷,是因为随着java的发展,现在有了太多的分支技术j2ee 13种技术,太多的框架(从底层到页面)如果要掌握还真不是件容易的事情,而且开源的东西永无止尽的在升级,在推陈 ......

java面试题3

23.编程实现序列化的Student(sno,sname)对象在网络上的传输
package com.softeem.demo;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.ServerSocket;
import java.net.Socket;
class Student implem ......

java第10天代码(线程)

/******************TestThread.java begin****************************/ 
public class TestThread {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Object obj=new Object();
  
  print p=new print(obj);
   ......

(摘)*java*ANT

ANT-build.xml文件详解
     
http://www.diybl.com/course/3_program/java/javajs/20081122/152210.html#
Ant的概念
可能有些读者并不理解什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令。当编
译Linux内核及一些软件的源程序时,经常要用这个命令。Make ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号