use of com.fsck.k9.mail.MimeType in project k-9 by k9mail.
the class MessageExtractor method getTextFromPart.
public static String getTextFromPart(Part part, long textSizeLimit) {
if (part == null) {
throw new IllegalArgumentException("Argument 'part' must not be null");
}
try {
Body body = part.getBody();
if (body == null) {
Timber.v("No body present for this message part");
return null;
}
if (body instanceof TextBody) {
TextBody textBody = (TextBody) body;
return textBody.getRawText();
}
String mimeType = part.getMimeType();
if (mimeType != null && MimeUtility.mimeTypeMatches(mimeType, "text/*") || part.isMimeType("application/pgp")) {
return getTextFromTextPart(part, body, mimeType, textSizeLimit);
}
Timber.w("Provided non-text part: %s", mimeType);
} catch (IOException | MessagingException e) {
Timber.e(e, "Unable to getTextFromPart");
}
return null;
}
Aggregations