Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

email with attachment using javax.mail to update Service Call

Highlighted
Vijay Kavrani
Esteemed Contributor

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 Subject : Update 14634

Fri, 22/06/2007 11:11:58 To : [servicecall]
Fri, 22/06/2007 11:11:58 Plaintext :
Attachment added.
Fri, 22/06/2007 11:11:58 Attachments: [(.\test.txt : D:\Program Files\Hewlett-Packard\OpenView\service desk 4.5\server\tmp\895-.\test.txt!#! : text/plain;name=.\test.txt)]
Fri, 22/06/2007 11:11:58 Reply-To : null
Fri, 22/06/2007 11:11:58 Reply-To :
Fri, 22/06/2007 11:11:58 Mail from : tony.2.marshall@bt.com

Fri, 22/06/2007 11:11:58 ReturnPath : tony.2.marshall@bt.com
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?

//Add this to "OnDomLoad" event