Object obj = attachments.elementAt(i);
if (obj instanceof File) {
File file = (File)obj;
if (file.isFile() && file.exists() && file.length() > 0) {
mimeBodyPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(file);
MimetypesFileTypeMap map = new MimetypesFileTypeMap();
map.addMimeTypes(getTypeEntry(file));
fds.setFileTypeMap(map);
mimeBodyPart.setDataHandler(new DataHandler(fds));
mimeBodyPart.setFileName(file.getName());
mimeBodyPart.setDisposition(getDisposition(file));
mimeMultipart.addBodyPart(mimeBodyPart);
}