2012-02-02 60 views
0

我正在從用JavaMail API我的收件箱中的郵件我的Android應用程序,的Android閱讀郵件用JavaMail API

是有可能「只是」有郵件正文以「content.toString()」?如果可能的話,我如何使用適配器查看郵件正文部分?我嘗試過SimpleAdapter和SimpleCursorAdapter,但內容是一種Object,不適合適配器。

你提供什麼?

謝謝。

private Message message; 
private Object content; 

message = inboxReader.inbox.getMessage(Integer.parseInt(_bundle.getString("RowId").toString())); 
content = message.getContent(); 

回答

2

也許你可以試試

private static String getMailContent(Multipart multipart) throws IOException, MessagingException{ 
    StringBuffer content = new StringBuffer(); 
    for (int i = 0; i < multipart.getCount(); i++) { 
     BodyPart bodyPart = multipart.getBodyPart(i); 
     String disposition = bodyPart.getDisposition(); 
     if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT))) { 
       // ................................ 
     } else { 
      content.append(bodyPart.getContent()); 
     } 
    } 
    return content.toString(); 
}