⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jfmgetemail.java

📁 java邮件源程序
💻 JAVA
字号:
/* * Created on 2004.08.25 * JFreeMail - Java mail component * Copyright (C) 2004 Dalibor Krleza *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */ package org.jfreemail.demo;import org.jfreemail.pop3.*;import org.jfreemail.core.*;/** * This demo shows how to download wanted E-mail choosed among * previously downloaded E-mail headers. */public class JfmGetEmail {	public static void main(String[] args) {		try {			/*			 * We are making pop object. Immediate authentication. If not			 * thrown exception, object is ready for use.			 */			JfmPOP3 pop=new JfmPOP3("pop.server.domain",0,				JfmConsts.POP3_APOP,"dalibor","secret111");			/*			 * Download all headers.			 */			JfmEmailHeader[] email_headers=pop.getMailboxHeaders();			/*			 * Here goes E-mail choosing. Client choses wich mail to download.			 * We are dowloading E-mail for first downloaded E-mail header			 * with index 0. E-mail leaves on POP3 server. We don't want to			 * delete readed E-mail.			 */			JfmEmail email=pop.getEmail(email_headers[1],false);			/*			 * Print e-mail.			 */			System.out.println("Sender:"+email.getEmailHeader().getFrom());			System.out.println("Receiver:"+email.getEmailHeader().getTo(0));			System.out.println("CC list");			for(int i=0;i<email.getEmailHeader().getCCCount();i++)				System.out.println("CC addr"+String.valueOf(i+1)+":"+email.getEmailHeader().getCC(i));			System.out.println("Subject:"+email.getEmailHeader().getSubject());			for(int i=0;i<email.getEmailPartCount();i++) {				if (email.getEmailPart(i) instanceof JfmEmailTextPart) {					/*					 * We have run onto text message. We should print this message					 * out. Warning: Every string in list ends on CRLF chars, so we					 * will not use println command.					 */					JfmEmailTextPart part=(JfmEmailTextPart)email.getEmailPart(i);					System.out.println("***Follows message with:"+part.getContentType()+" mime/type and "+						part.getContentCharset()+" charset");					String[] message=part.getContent();					for(int j=0;j<message.length;j++) System.out.print(message[j]);				} else if (email.getEmailPart(i) instanceof JfmEmailBinaryPart) {					/*					 * We have run onto binary attachment. For now, we will print					 * only filename and size.					 */					JfmEmailBinaryPart part=(JfmEmailBinaryPart)email.getEmailPart(i);					System.out.println("***Attachment with filename:"+part.getContentName()+						" size:"+String.valueOf(part.getContent().length));				}			}			/*			 * Close connection to POP3 server.			 */			pop.close();		} catch(Exception exc) {			System.out.println(exc.getMessage());		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -