• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Attachment in Java to send email  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am new to Java. I am trying to send an email through Java code. I have below code snippet. When I am sending email, java code is sending out the full name of the file with directory. How do i remove/trim the directory name here.

For example: I have file in the path C:\\OIMDocs\\data.csv, Java is sending out as COIMDocsdata.csv. How do i remove COIMDocs from the file while sending.



Please help me out
 
Rancher
Posts: 486
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oneway would be to add it as a resource and use the relative path
 
Sheriff
Posts: 23866
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have these two lines of code:





Now, you don't like the result when you use the filename variable in the second line of code. In that case I'd suggest you decide what you want to send as the attachment's "file name" instead, and use that value as the parameter of the setFileName() method. As far as I know you can use anything in that method, in particular what you send doesn't need to have any relation to the name of the physical disk file which is being attached. You could use "attachment.csv" for example -- but I should let you decide what you want to use.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!