这样就好了
topic = new String(topic,"GB2312");

解决方案 »

  1.   

    不好意思刚才看错了应该是这个方法MimeMessage.setSubject(topic, "gb2312");
      

  2.   

    能否不用java mail的包呢?我想自己实现POP3,现在就是如何把一个字符串汉化的问题
      

  3.   

    topic = new String(topic.getBytes("源格式"),"GB2312");
      

  4.   

    我觉得它的源格式应该是gb2312了,看这个字符串“Subject: =?gb2312?B?xOO6ww==?=”本身就含有一个"gb2312"。但就是解不出来中文。这封邮件时是用OUTLOOK发的,假如用OUTLOOK接收能够很好地显示成中文“你好”,但JAVA就是不晓得怎么解。
      

  5.   

    邮件Subject的编码问题 一般是base64
      

  6.   

    public static String parseSubject(String string){
        String str = "";
        if(string==null)return "";
        try {
            if(string.startsWith("=?GB")||string.startsWith("=?gb")){
                str=MimeUtility.decodeText(string); 
            }else  if(string.toLowerCase().startsWith("=?big5")){
            
             str = charToBig(MimeUtility.decodeText(string)) ;
            
            }else if(string.toLowerCase().startsWith("=?utf-8")){
            
             str = charToUTF(MimeUtility.decodeText(string));
            }else {
            
               str = charTogb(MimeUtility.decodeText(string));
            }
            
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return str;
    }

    public static  String charTogb(String string) throws UnsupportedEncodingException{
           return new String(string.getBytes("ISO-8859-1"),"GBK");
    }

    public static  String charToBig(String string) throws UnsupportedEncodingException{
           return new String(string.getBytes("big5"),"GBK");
    }

    public static  String charToUTF(String string) throws UnsupportedEncodingException{
           return new String(string.getBytes("UTF-8"),"GBK");
    }
      

  7.   

    str=MimeUtility.decodeText(string);一句是解决问题的关键!多谢“XQC”!给分当然没的说!