获取的HTML邮件内容中的JavaMail [英] Getting html Email Content in JavaMail

查看:1101
本文介绍了获取的HTML邮件内容中的JavaMail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个电子邮件客户端我使用JavaMail API Android-电话。我不knoq如何得到电子邮件的内容,如果它是一个HTML的邮件。我用下面的code获取内容:

I've made an E- Mail Client for my Android- Phone using the JavaMail API. I dont knoq how to get the E- Mail Content if it's a html- Mail. I'm using the following Code to get the Content:

public void printMessage(int messageNo) throws Exception {
    Log.i("MsgNo", "Getting message number: " + messageNo);

    Message m = null;

    try {
        m = folder.getMessage(messageNo);
        dumpPart(m);
    } catch (IndexOutOfBoundsException iex) {
        Log.i("Out of Range","Message number out of range");
    }
}

public static void dumpPart(Part p) throws Exception {

    if (p instanceof Message)
        dumpEnvelope((Message)p);
    Object content = p.getContent();
    Log.i("dumpPart",(String) content);
    String ct = p.getContentType();
    try {
        pr("CONTENT-TYPE: " + (new ContentType(ct)).toString());
        Log.i("MsgNo", "Content Type");
    } catch (ParseException pex) {
        pr("BAD CONTENT-TYPE: " + ct);
        Log.i("MsgNo", "Bad Content Type");

    }


     //* Using isMimeType to determine the content type avoids
   //  * fetching the actual content data until we need it.

    if (p.isMimeType("text/plain")) {
        pr("This is plain text");
        pr("---------------------------");
        Log.i("Text", (String)p.getContent());       
    } else {
         Log.i("MsgNo", "Just a Separator");
        // just a separator
        pr("---------------------------");

    }
}

在logcat中,我得到dumpenvelope((消息)P)的返回值; ,但没有什么了。

In the Logcat, i get the return value of dumpenvelope((Message)p); , but after that nothing.

有谁知道该怎么办?

推荐答案

时,任何异常抛出?

你有没有使调试并检查协议跟踪,看看有什么可能已经失败了?

Did you enable debugging and examine the protocol trace to see what might have failed?

您使用IMAP?

它看起来像你的程序创建了名为msgshow.java了JavaMail示例程序块,你有没有发现完整的原始样本程序?

It looks like your program was created out of pieces of the JavaMail sample program called msgshow.java, did you find the complete original sample program?

这JavaMail的FAQ条目可能有所帮助

这篇关于获取的HTML邮件内容中的JavaMail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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