aspose file tools*
The moose likes Java in General and the fly likes How to set the Content type in JavaMail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to set the Content type in JavaMail" Watch "How to set the Content type in JavaMail" New topic
Author

How to set the Content type in JavaMail

arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
Hello Everybody,
I was trying to do the following in my send mail program:-
1. I am making a file using FileWriter:
FileWriter fw = new FileWriter(f);
fw.write(str);
2. I now want to attach this file with my mail. but before that I want to set the Content type of this as "application/smil". and trying the following code:
mimebodyparts[0].setContent(fds[0],"application/smil");

But when I recieve the mail and check the content type it shows "application/octet-stream".
I'd be highly obliged if some body help me to set the content type right for the above.
regards,
Arun
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
I tired to dig into further and found that it is senidng the mail as I am trying to et the content type at wrong position and the program as not able to determine the ontent type is setting as octet-stream.
Now new problem has arised after putting the code right. While trying to send the mail it throws an exception
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/smil
I tried to find the answer into th enet and got that I need to change the mailcap file. I found the same in the activation jar package but thought instead of chagning the default file i tried putting following code in my program:

and in simple.mailcap file put the following value

but the problem still persists.
Can somebody Please help to sort this out.
regards,
Arun
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
Oops no taker for this question....I thought this is the best forum at javaranch...Can you take care for me Cindy?
Arun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set the Content type in JavaMail
 
Similar Threads
Is it possible to change the Content-type field of a mail
Is it possible to change the Content-type field of a mail
adding SOAP attachment
Extracting SOAP Attachments!! Help!!
SAAJ - SOAP attachment