Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail:getting the extension of an attachment file  RSS feed

 
glok art
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Currently i am facing an issue wherein I need to determine the extension of the attachment file in a particular mail.The attachment file in question is an "eml" file. I need to parse mails using JavaMail and identify whether the attachment file is of type ".eml" or not.

I have a sample mail which contains an attachment of "eml" type.
I am able to get the "part" object for the attachment.I have tried using

1.part.getDisposition() => null
2.part.getFileName() => null
3.part.getAllHeaders() => Content-Type: message/rfc822 , Content-Disposition: inline , Content-Transfer-Encoding: 7bit
4.PartUtils.getContentType(part) => MESSAGE/RFC822
5.PartUtils.getEncoding(part) => 7BIT
6.PartUtils.getMimeBaseType(part) => MESSAGE/RFC822

All these do not help in uniquely identifying an attachment as of "eml" type.Is there any way to get the extension of the attachment file?
Any other suggestions are welcome too.

Thanks in advance.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no requirement to assign a filename to an e-mail attachment. (You do realize that the "extension" you're asking about is simply the last part of the filename, don't you?) So if the sender doesn't assign a filename there is no way to get a filename.

However if you go back one step in your requirements, you will notice that the content type of the message is "message/rfc822". I suspect this may be what you are really looking for.
 
Nishant Modak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was facing a same situation.

In that case I asked the sender to send me the filename as a field of the incoming request object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!