When im saving an attachment with my Web Mail in the dialog box always appears the world "attachment" instead of the name of the file, obviously i want the real name of the file, how can i do this? Here is a part of my code: Message msg = mailuser.getFolder().getMessage(msgNum); Multipart multipart = (Multipart)msg.getContent(); Part part = multipart.getBodyPart(partNum); String sct = part.getContentType(); if (sct == null) { out.println("invalid part"); return; } ContentType ct = new ContentType(sct); response.setContentType(ct.getBaseType()); InputStream is = part.getInputStream(); int i; while ((i = is.re
More>>

When im saving an attachment with my Web Mail in the dialog box always appears the world "attachment" instead of the name of the file, obviously i want the real name of the file, how can i do this?

What do you mean by the "real name of the file"? It is not a "file", it is an "attachment", part of a MIME message structure. It may have come from a file, originally, on the sender's computer, and it may be intended to be saved as a new file on the recipient's computer, but those are all different animals (perhaps with entirely different names).

Do you mean, maybe, that you know the sender's mail software, which generated the message with the attachment, included a "content-disposition" header, giving a filename in it, and you want to get the filename given in this header?

Otherwise, if there is no suggestion of an intended filename in the MIME headers of the message, then you have no "filename" to obtain in the first place (unless you can go and ask the sender, what was the filename of the file they attached to the message).