Note that there are some explanatory texts on larger screens.

plurals
  1. POTeaching javax.mail, javax.activation to recognize mime type of mail attachment in web application
    text
    copied!<p>Im sending mails from a web application running on a glassfish server, which was quite easy with the java mail API.</p> <p>I'm starting now to attach files (mainly pdf and odt) to the mail, which works to, but the mime type of the attachment is not correctly set (application/octet-stream). I tried to attach the file with:</p> <pre><code>MimeBodyPart mimeBodyPart = new MimeBodyPart(); mimeBodyPart.attachFile(file); </code></pre> <p>and: </p> <pre><code>messageBodyPart = new MimeBodyPart(); FileDataSource source = new FileDataSource(file); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(file.getName()); </code></pre> <p>But its the same result. From <a href="http://java.sun.com/products/javamail/FAQ.html#filetype" rel="nofollow noreferrer">here</a> i have the hint to place a mime.types file in the META-INF folder of my application but this does not seem to work for me. I tried id in the META-INF of the war and the ear of my application.</p> <p>Enabling debug for javax.activation gives me this:</p> <blockquote> <p>INFO: MimetypesFileTypeMap: load HOME</p> <p>INFO: MimetypesFileTypeMap: load SYS</p> <p>INFO: MimetypesFileTypeMap: load JAR</p> <p>INFO: MimetypesFileTypeMap: !anyLoaded</p> <p>INFO: MimetypesFileTypeMap: not loading mime types file: /META-INF/mime.types</p> <p>INFO: MimetypesFileTypeMap: load DEF</p> </blockquote> <p>Where do i have to put the mime.types file or how can a mime types to my web application?</p> <p>Thanks Raffael</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload