attachments to e-mail?
<p>I've got something like the following...</p>

<pre><code>   public boolean sendmail (String host, String to, String from,
String message, String subject, String cc){
      try
      {
         //Created TCP Connection to server
         Socket s = new Socket(host, 25);
         //Open our streams.
         InputStream inStream = s.getInputStream();
         OutputStream outStream = s.getOutputStream();
         in = new Scanner(inStream);
         out = new PrintWriter(outStream, true );
         //get my info!
         String hostName = InetAddress.getLocalHost().getHostName();
         //e-mail time!

         receive();
         send("HELO" + host);
         receive();
         send("MAIL FROM: &lt;" + from + "\n");
         receive();
         send("RCPT TO: &lt;" + to + "\n");
         receive();
         send("DATA");
         receive();
         send("DATA");
         receive();
         //Make sure to close the everything again!!
         out.close();
         in.close();
         s.close();
         return true;
      }
      catch (Exception e)
      {
          appendtolog("ERROR: " + e);
          return false;
      }
   }

private void send(String s) throws IOException{
    appendtolog(s);
    out.print(s.replaceAll("\n", "\r\n"));
    out.print("\r\n");
    out.flush();
}

private void receive(){
    String line = in.nextLine();
    appendtolog(line);
}
</code></pre>

<p>is it possible to just put an attachment somewhere in there? I realise there is ways of doing this using the API more but I'm wondering there a way I can hammer functionality for attachments into that or is using something like.. </p>

<pre><code>// Set the email attachment file
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fileDataSource = new FileDataSource(filename) {
@Override
public String getContentType() {
  return "application/octet-stream"; 
}
 };
 attachmentPart.setDataHandler(new DataHandler(fileDataSource));
  attachmentPart.setFileName(filename);
</code></pre>
