开发者

Only download specific MIMETYPE with JavaMail

Each message that I am downloading is quite large. However, I am only interested in the JSON MIMETYPE. Is there a w开发者_运维知识库ay to specify to the server that I am would only like to download the JSON part of the message? I have looked into the FetchProfile settings, but it does not seem to support this.


I supposed that you are using javamail and have been able to retrieve the messages right?

Perhaps you can try this: Get the bodypart and check for the mimetype.

        if (part.isMimeType("text/plain")) {
            // Handle plain text
            Log.i("Mime Type: ", "Plain Text!");
        } else {
            // Special non-attachment cases here of
            // image/gif, text/html, ...
            Log.i("Mime Type: ", "Others!");
        }


Once you're at the stage of downloading the message contents it's an all-or-nothing situation, unfortunately. The standards that JavaMail adheres to don't specify a way to separate parts of message contents before downloading; the only way to accomplish that sort of thing would be server-side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜