我在apche james的mailet写了这样几句代码:后面还有 
                if(part.isMimeType("text/plain")){
                            email_content=(String)part.getContent();}else邮件中是:
Content-Type: text/plain; charset=unicode-1-1-utf-7This is an automatically generated Delivery Status Notification.Unable to deliver message to the following recipients, due to being unable to connect successfully to the destination mail server.       [email protected]

解决方案 »

  1.   

    public String getMessageText(Message message) throws 
    java.io.IOException,javax.mail.MessagingException
      {
        String body = null;    Object o = message.getContent();    if (o instanceof MimeMultipart)
        {
          MimeMultipart mm = (MimeMultipart)o;
          mm = (MimeMultipart)o;
          BodyPart bp = null;        for(int j = 0; j < mm.getCount(); j++)
            {
              bp = mm.getBodyPart(j);          try
              {
                o = bp.getContent();
              }
              catch (IOException e)
              {
                if (bp.getContentType().equals("text/plain; charset=unicode-1-1-utf-7"))
                {
                  ByteArrayOutputStream bao = new ByteArrayOutputStream();
                  bp.writeTo(bao);
                  body = bao.toString();
                }
                break;
              }          if (o instanceof MimeMessage)
              {
               body = ((MimeMessage)o).getContent().toString();
               break;
              }
              else if (o instanceof String)
              {
                body = (String)o;
                break;
              }
            }
        }
        else
        {
          body = message.getContent().toString();
        }
        return body;
      }试试看,希望对你有用
      

  2.   

    谢谢你~,分全给你了老板后来给我说,以后的电邮不会出现UTF-7的编码所以那个不用处理
      

  3.   

    原帖参考http://hi.baidu.com/yylaob/blog/item/436e75304f421284a9018ebf.html#0