email with attachment using javax.mail to update Service Call
Hi, I am using javax.mail.* classes to send an attachment to a Service call. There is a Domino server as SMTP Relay Host to which this update mail goes.
The Code looks like:
Multipart multipart = new MimeMultipart(); // Add part one multipart.addBodyPart(messageBodyPart); // Part two is attachment // Create second body part messageBodyPart = new MimeBodyPart(); // Get the attachment DataSource source = new FileDataSource(filename); // Set the data handler to the attachment messageBodyPart.setDataHandler(new DataHandler(source)); // Set the filename messageBodyPart.setFileName(filename); // Add part two multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send the message Transport.send(message);
And here is the problem (what I see in logserver.txt):
Fri, 22/06/2007 11:11:58 ReturnPath : firstname.lastname@example.org Fri, 22/06/2007 11:11:58 Importance : normal Fri, 22/06/2007 11:11:58 Error when put file D:\Program Files\Hewlett-Packard\OpenView\service desk 4.5\server\tmp\895-.\test.txt!#! to attachment server: java.io.FileNotFoundException: D:\Program Files\Hewlett-Packard\OpenView\service desk 4.5\server\tmp\895-.\test.txt!#! (The system cannot find the path specified)
The problem is that the attached file test.txt is being received on Service Desk server as .\test.txt and these two extra characters ".\" are creating an issue here. I am not sure where these two characters are getting inserted. Can anyone help please?