title: part.isMimeType == "Multipart/*" Does it mean it has an attachment?
body: <p>I have an email project in Android and I can receive and download my mails and its attachments but now I want to learn if a message has an attachment or not, and how many attachments it has got.</p>
  
  <p>I mean I just need to do an if clause like:</p>
  
  <pre><code>if(messages[i].hasAttachment)
  {
     int numberOfAttachments = messages[i].attachmentNumber;
    // do smthng
  }
  else
  {
    // do smthng
  }
  </code></pre>
  
  <p>Maybe its help: I am receiving my body part with this code sample. Meanwhile, as per my subject, if the isMimeType = "Multipart/alternative" or "Multipart/*" , does it mean it has an attachment?</p>
  
  <pre><code>public String getText(Part p) throws MessagingException, IOException {
  
          if (p.isMimeType("text/*")) {
              boolean textIsHtml = false;
              String s = (String) p.getContent();
              textIsHtml = p.isMimeType("text/html");
              return String.valueOf(s);
          }
  
          if (p.isMimeType("multipart/alternative")) {
              // prefer html text over plain text
              Multipart mp = (Multipart) p.getContent();
              String text = null;
              for (int i = 0; i &lt; mp.getCount(); i++) {
                  Part bp = mp.getBodyPart(i);
                  if (bp.isMimeType("text/plain")) {
                      if (text == null)
                          text = getText(bp);
                      continue;
                  } else if (bp.isMimeType("text/html")) {
                      String s = getText(bp);
                      if (s != null)
                          return String.valueOf(s);
                  } else {
                      return getText(bp);
                  }
              }
              return text;
          } else if (p.isMimeType("multipart/*")) {
              Multipart mp = (Multipart) p.getContent();
              for (int i = 0; i &lt; mp.getCount(); i++) {
                  String s = getText(mp.getBodyPart(i));
                  // fileName = bp.getFileName();
                  if (s != null)
                      return String.valueOf(s);
              }
          }
  
          return null;
      }
  </code></pre>