Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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: 309
6
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: 23647
49
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!