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,也就是选择了一条光明而坎坷的道路。说他光明是因为应用的地方日益广泛,全球有很大的开发群体在为之忙碌,开源项目应有尽有;说他坎坷,是因为随着java的发展,现在有了太多的分支技术j2ee 13种技术,太多的框架(从底层到页面)如果要掌握还真不是件容易的事情,而且开源的东西永无止尽的在升级,在推陈 ......
工作需要,针对java文件,作了一个行数统计的工具。统计的主要代码如下:
Set srcIn = fso.OpenTextFile(fileNm, ForReading)
Do While Not srcIn.AtEndOfStream
buf = srcIn.ReadLine
&nbs ......
1. python是一种弱类型的脚本语言,在给变量赋值是无需指定变量的类型,例如:
x=1 #(整型)-------范围在-2^31->2^31
x=2345L &n ......
源代码:
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class brandishString extends Applet implements Runnable, MouseListener {
String str; // 要显示的字符 ......
中文的编码常用的有3种格式:1)gb2312(就是ascii码方式,也说ansi) 2)unicode 3)utf-8
c++一般采用ancii码,而java一般采用unicode,而SymbianC++(以后简称symbian)采用unicode或utf-8
比如汉字“好”: unicode为“7D 59”,而ascii为“BA C3”, utf-8编码为3个字节。
终端你 ......