//Create an empty body part
messageBodyPart=new MimeBodyPart();
//Create a new DataSource,passing it the attachment file
DataSource source=new FileDataSource(fileName);
//Set the data handler
messageBodyPart.setDataHandler(new DataHandler(source));
DataHandler对象为不同的数据源和数据格式提供一致的接口,比如一个图像或一个输入流.