title: Extracting attachment from email received on google app engine
body: <p>I want to extract an attachment from mail received in my GAE java app. The attachment will be an image file: JPG, PNG, GIF, etc. I am using Restlet framework in my GAE project. So I extract MimeMessage from Restlet's representation object. But I can't figure out how to extract the image file which came as attachment with the mail.</p>
  
  <p>Below is the code I am using to extract MimeMessage:-</p>
  
  <pre><code>@Post 
  public Representation addPoints(Representation entity) {
      Properties props = new Properties(); 
      Session session = Session.getDefaultInstance(props, null); 
      try {
          MimeMessage message = new MimeMessage(session, entity.getStream());
      } catch (MessagingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>