title: Save attachments NodeJS
body: <p>I'm using a NodeJS library(yapople) to read emails from my pop3 server.  The problem I'm coming across is downloading the attachments.  Not sure how to exactly do this.  I get back a mailparser object where I see the attachments. This is what I have so far.</p>
  
  <pre><code>var fs = require('fs');
  const simpleParser = require('mailparser').simpleParser;
  
  var Client = require('yapople').Client;
  var client = new Client({
    hostname: 'xxxxxxx',
    port:  995,
    tls: true,
    mailparser: true,
    username: 'xxxxx',
    password: 'xxxxx'
  });
  
  client.connect(function() {
  
      //I get an email with attachments
      client.retrieve(4327, function(err, messages){
          if(messages.attachments != null){
          for (var i in messages.attachments) {
              var attachment = messages.attachments[i];
              var data = attachment.content;
              fs.writeFile(attachment.fileName, data)
          }
      }
  
      })
      client.quit();
  })
  </code></pre>