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.
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.