// identify the service record associated with a mail message // service via a CID of 'CMIME' if (srs[cnt].getCid().equals("CMIME")) { ServiceConfiguration sc = new ServiceConfiguration(srs[cnt]); Store _store = Session.getInstance(sc).getStore();

if (mbp.getContentType().indexOf(ContentType.TYPE_TEXT_HTML_STRING) != -1) { // The message has no attachments. // Read the email body, which may contain a TexBodyPart, // MimeBodyPart or both. readEmailBody(mbp); } else if (mbp.getContentType().equals( ContentType.TYPE_MULTIPART_MIXED_STRING) || mbp.getContentType().equals( ContentType.TYPE_MULTIPART_ALTERNATIVE_STRING)) { // The message has attachments or we are at the top level of the // message. Dig deeper to find the body. // Extract all of the parts within the MimeBodyPart message. findEmailBody(mbp.getContent()); }

// Determine if the data returned is a String or a byte array. // If the BlackBerry is able to convert the HTML content into a String, // then a String should be returned. If the encoding is not supported a // byte array is returned to allow your application to work with the raw // data. if (obj instanceof String) { body = (String) obj; } else if (obj instanceof byte[]) { body = new String((byte[]) obj); }