• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JavaMail:getting the extension of an attachment file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic