msg.addAttachment (new FileInputStream (f));
{ msg.addAttachment (new FileInputStream (f), null, MIMETypeUtil.MIMETypeForFile (f)); }
    private void sendEmail()        throws EmailException,               IOException    {        // Add the text part.        if (text != null)            msg.setText (text, textMimeType);        else if (textFile != null)        {            if (useInputStreams)                msg.setText (new FileInputStream (textFile), textMimeType);            else                msg.setText (textFile);        }        // Add any attachments specified as files.        for (Iterator it = attachmentFiles.iterator(); it.hasNext(); )        {            File f = (File) it.next();            if (useInputStreams)                msg.addAttachment (new FileInputStream (f));            else                msg.addAttachment (f);        }        // Do any dumping...        if (dumpTextPart)        {            if ( (text = msg.getText()) != null )            {                out.println ("------------------");                out.println ("Text part follows:");                out.println ("------------------");                System.out.print (text);                System.out.flush();                out.println ("------------------");                out.println ("End of Text part");                out.println ("------------------");            }        }        // Send the message.        String sep;        out.println ("Sending message");        EmailAddress sender = msg.getSender();        out.println ("From: " + sender.toString());        out.println ("To: " + TextUtil.join (msg.getTo(), ", "));        if (msg.getCc().size() > 0)            out.println ("Cc: " + TextUtil.join (msg.getCc(), ", "));        if (msg.getBcc().size() > 0)            out.println ("Bcc: " + TextUtil.join (msg.getBcc(), ", "));        out.println ("Subject: " + msg.getSubject());        transport.send (msg);    }