Android的JAVAMAIL接收电子邮件 [英] Android Javamail receive email

查看:259
本文介绍了Android的JAVAMAIL接收电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JavaMail接收电子邮件的Andr​​oid系统。

I use the JavaMail to receive emails in Android.

问题是:
Message.getContent()总是返回 SharedByteArrayInputStream
 以及

Problem is: Message.getContent() always return SharedByteArrayInputStream. And

Bodypart.getContent()总是返回 BASE64De coderStream QRDe coderStream

我读了JavaMail'FAQ,它说:

I read the JavaMail'FAQ, it says:

问:当读取一个多部分消息,为什么是的getContent方法返回一个 IMAPInputStream(或SharedByteArrayInputStream),而不是 MimeMultipart的对象?

Q: When reading a multipart message, why is the getContent method returning an IMAPInputStream (or SharedByteArrayInputStream) instead of a MimeMultipart object?

答:这通常是因为JavaBeans激活框架(JAF)找不到包含在mail.jar文件mailcap中的配置文件。 JAF使用线程的上下文类加载器来查找配置文件。如果未设置上下文类加载正确,这可能会失败。大多数应用服务器应该正确设置上下文类加载器,而Tomcat的至少一些版本不。一个解决办法是把Tomcat的lib目录mail.jar文件,而不是把它包含在war文件。另一个解决方法是添加code,如下列您的应用程序的开头:

A: This usually happens because the JavaBeans Activation Framework (JAF) can't find the mailcap configuration file included in the mail.jar file. JAF uses the thread's context class loader to look for the configuration file. If the context class loader is not set properly, this can fail. Most application servers should set the context class loader properly, but at least some versions of Tomcat do not. One workaround is to put the mail.jar file in Tomcat's lib directory instead of including it in the war file. Another workaround is to add code such as the following to the beginning of your application:

Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

但我不知道如何在Android的解决这个问题。是否有任何人能帮助我吗?

But i don't know how to fix this problem in Android. Is there anybody can help me?

推荐答案

我觉得你是错误的使用jar文件

i think you are using wrong jar file

下载罐

和更多信息遵循<一个href=\"http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a\">this

这篇关于Android的JAVAMAIL接收电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆