我在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]
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]
解决方案 »
- 求助,java中怎么统计流量和处理文字???
- 求正则表达式阿
- 文本框赋值问题
- doubleselect 中doubleHeaderValue请教
- jdbc连接sqlserver在tomcat中运行出现这种问题?帮忙看看
- 求~~~~~~~~~~~~~~~~
- 部署时Eclipse为什么不会把spring-web.jar拷贝到项目的lib里去?
- struts高级问题探讨!!!(怎么使一个action每天执行一次)
- hibernate能不能存取数据库里的二进制文件?
- Java不能识别PDF文件吗
- java开源框架的源代码怎么读,我看这没什么头绪的
- java.lang.NoClassDefFoundError: org/apache/commons/httpclient/Credentials
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;
}试试看,希望对你有用