资源简介

JBuilder开发。javamail开发的简单的邮件收发,SWing做为前端界面。能够支持多种邮箱,由于有几种邮箱协议不是很清楚,可能有问题。只需简单修改就能适用另外的邮箱。如有问题,可与本人联系。本人QQ 573270725 内附带一邮件收发实现的基本功能的文本,在基础上可任意扩充。谢谢

资源截图

代码片段和文件信息

package mail.bean;

import javax.mail.Message;
import javax.mail.internet.MimeUtility;
import sun.misc.base64Decoder;

/**
 * 

title: 


 *
 * 

Description: 


 *
 * 

Copyright: Copyright (c) 2008


 *
 * 

Company: 


 *
 * @author not attributable
 * @version 1.0
 */
public class Trans {
    public Trans() {
    }

    //接收邮件时,某些邮件发送程序发送的email地址,发送地址显示为乱码的解决方法
    public static String getFrom(Message msg){
    String from=““;
    try{
        if(msg.getFrom()[0]!=null)
            from=msg.getFrom()[0].toString();
        if(from.startsWith(“=?GB“) || from.startsWith(“=?gb“))
            from=MimeUtility.decodeText(from);
        else
            from=toChinese(from);
    }catch(Exception ex){
        ex.printStackTrace();
    }
    return from;
  }


  public static String toChinese(String strValue){
      try{
          if(strValue==null)
              return null;
          else{
              strValue=new String(strValue.getBytes(“iso8859-1“)“GBK“);
              return strValue;
          }
      }catch(Exception ex){
          return null;
      }
  }

  /*接收邮件时,获取某个邮件的中文附件名,出现乱码
  解决办法,对于用base64编码过的中文,则采用base64解码,否则对附件名进行iso8859-1到gbk的编码转换,例如
  */

 public static String getBody(Message message)throws Exception{
     String temp=message.getFileName();
     if((temp.startsWith(“=GBK?B?“) && temp.endsWith(“?=“)) || (temp.startsWith(“=gbk?b?“) && temp.endsWith(“?=“)))
         temp=getFrombase64(temp.substring(8temp.indexOf(“?=“)-1));
     else
         temp=toChinese(temp);
     return temp;
 }

 public static String getFrombase64(String s){
     if(s==null) return null;
     base64Decoder decoder=new base64Decoder();
     try{
         byte[] b=decoder.decodeBuffer(s);
         return new String(b);
     }catch(Exception ex){
         return null;
     }
 }

 //删除二维数组中指定下标处
 public static object[][]  deleteRecord(object[][] objectint index){
     object[][] temp=new object[object.length-1][];
     int j=0;
     for(int i=0;iject.length;i++){
         temp[j]=object[i];
         j++;
         if(i==index){
             j--;
         }
     }
     return temp;
 }

 //删除一维数组指定下标处
 public static object[] deleteRecord(object[] objectint index){
     object[] temp=new object[object.length-1];
     int j=0;
     for(int i=0;iject.length;i++){
         temp[j]=object[i];
         j++;
         if(i==index){
             j--;
         }
     }
     return temp;
 }

    public static void main(String[] args) {
        Trans trans = new Trans();
    }
}


















 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4967  2008-05-15 15:25  SendMail\SendMail.jpx

     文件       3610  2008-05-15 16:47  SendMail\SendMail.jpx.local

     文件       3246  2008-05-15 16:47  SendMail\SendMail.jpx.local~

     文件       9544  2008-05-15 12:51  SendMail\src\mail\from\SendMail.java

     文件        700  2008-05-14 12:51  SendMail\src\mail\from\MyPasswordAuthenticator.java

     文件      10383  2008-05-15 15:09  SendMail\src\mail\from\ReceiveMail.java

     文件       2779  2008-05-15 12:38  SendMail\src\mail\bean\Trans.java

     文件       1932  2008-05-14 11:54  SendMail\src\swing\table\ButtonTableCellEditor.java

     文件        801  2008-05-14 11:55  SendMail\src\swing\table\ButtonTableCellRenderer.java

     文件       1781  2008-05-14 11:49  SendMail\src\swing\table\EditableTableModel.java

     文件        825  2008-05-14 15:50  SendMail\src\swing\component\MouseEventTable.java

     文件        712  2008-05-15 16:13  SendMail\src\swing\exercise\ShowHTML.java

     文件      18024  2008-05-15 15:09  SendMail\classes\package cache\mail.from.dep2

     文件       1771  2008-05-15 12:43  SendMail\classes\package cache\mail.bean.dep2

     文件        951  2008-05-14 16:11  SendMail\classes\package cache\swing.component.dep2

     文件       3576  2008-05-14 12:51  SendMail\classes\package cache\swing.table.dep2

     文件       1161  2008-05-15 15:41  SendMail\classes\package cache\swing.exercise.dep2

     文件       8627  2008-05-15 13:36  SendMail\classes\mail\from\SendMail.class

     文件        679  2008-05-15 13:36  SendMail\classes\mail\from\SendMail_jButton1_actionAdapter.class

     文件        674  2008-05-14 12:51  SendMail\classes\mail\from\MyPasswordAuthenticator.class

     文件       8312  2008-05-15 15:09  SendMail\classes\mail\from\ReceiveMail.class

     文件        697  2008-05-15 15:09  SendMail\classes\mail\from\ReceiveMail_jButton1_actionAdapter.class

     文件        697  2008-05-15 15:09  SendMail\classes\mail\from\ReceiveMail_jButton2_actionAdapter.class

     文件       2960  2008-05-15 15:09  SendMail\classes\mail\from\ReceiveMail$1.class

     文件       2585  2008-05-15 12:43  SendMail\classes\mail\bean\Trans.class

     文件       1724  2008-05-14 12:51  SendMail\classes\swing\table\ButtonTableCellEditor.class

     文件       1093  2008-05-14 12:51  SendMail\classes\swing\table\ButtonTableCellRenderer.class

     文件       1417  2008-05-14 12:51  SendMail\classes\swing\table\EditableTableModel.class

     文件       1032  2008-05-14 16:11  SendMail\classes\swing\component\MouseEventTable.class

     文件       1083  2008-05-15 15:41  SendMail\classes\swing\exercise\ShowHTML.class

............此处省略104个文件信息

评论

共有 条评论