Luc,
Another little trick to make this code more portable (ie: being able to
save the file after it's been downloaded to Unix or NT) would be to use the
'File.separator' character in lieu of the \\ like so:
String correctFileName =
filename.substring(filename.lastIndexOf(File.separator));
Erik Sahl
[EMAIL PROTECTED]
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Luc
> Saint-Elie
> Sent: Tuesday, September 21, 1999 8:31 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [SERVLET/JAVAMAIL ] name of mailed files
>
>
> As usual you're right Craig,
>
> in case it could help others the right piece of code is:
> // attach the file to the message
> FileDataSource fds=new FileDataSource(filename);
> mbp2.setDataHandler(new DataHandler(fds));
> String correctFileName =
> filename.substring(filename.lastIndexOf("\\") + 1);
> mbp2.setFileName(correctFileName );
>
>
>
> Le 10:05 21/09/99 -0700, Craig R. McClanahan a �crit:
> > [snip]
> > MimeBodyPart mbp2 = new MimeBodyPart();
> > // attach the file to the message
> > FileDataSource fds=new FileDataSource(filename);
> > mbp2.setDataHandler(new DataHandler(fds));
> > mbp2.setFileName(filename);
> > [snip]
>
> Can't you just strip off the directory part of "filename" before you call
> setFileName()? By that point, you've already set up the data
> source for the
> attachment, so JavaMail knows where to find it. My understanding is that
> whatever you set with setFileName() is the proposed filename that
> the message
> receiver sees.
>
> __________________________________________________________________
> _________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html