JavaMail API を使用して、Android Phone 用の電子メール クライアントを作成しました。HTML メールの場合、メール コンテンツを取得する方法がわかりません。次のコードを使用してコンテンツを取得しています。
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((Message)p); の戻り値を取得します。、しかしその後は何もありません。
何をすべきか知っている人はいますか?