When sending an attachment with JavaMail, I don't want the attachment to have the full directory path from the source. How do I shorten the name associated with the attachment?

John Zukowski

The MimeBodyPart class has a setFileName() method that allows you to specify any text you want. Just set it to the name of the FileDataSource:

MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = 
  new FileDataSource("c:/temp/foo.jpg");
mbp.setFileName(fds.getName());
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact