Search code examples
jsonimapjakarta-mailfetch

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 way 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.


Solution

  • 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!");
            }