• 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

JavaMail Attachment Error

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I'm working on adding some e-mailing capability to an existing reporting application.

I am able to generate a report and send it using JavaMail, however I can't seem to get the MIME types right. Know know the 5 MIME types I needs for the 5 formats I support, but they all are sent as .dat files. Upon arrival, if I convert the .dat file to the proper extensions(On Windows) then I can open the file just fine.

I tries using the MIMEBodyPart class's setContent method, but it keeps telling me:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/pdf



It says the same for all my other MIME Types, expect with the correct MIME type listed.

Here is the code:



Please note that getMIMEHeader returns a new javax.mail.Header object that has the value set to the MIMtype String.

Also, recipients is an ArrayList of type String that contains a listing of everyone the e-mail should be send to.

Thanks,

Jon
[ December 09, 2008: Message edited by: Jon Parise ]
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this will help any... I've always used the Apache Commons Email API when working with e-mail. It wraps the Java Mail API. I've always heard that working with the Java Mail API directly can be tricky. I've used Apache Commons Email for attachments as well. At the very least, you might be able to look at their source code (since it's open source) and see how they handle attachments and see if you are missing something. Anyhow, since I had not seen anyone reply to you yet, I thought that suggestion might help.
 
Jon Parise
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for letting me know about Commons. I'll give that a try, it does appear to be easier to use.

I am still curious about getting Java Mail to send nice attachments, so if anyone has a solution I would be interested to see.

Thanks again,

Jon
 
Our first order of business must be this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic