not working java mail application in other machine.
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, November 29, 2006 08:00 AM


I am developing a application which is send a mail when the user enters the data.
This is wooking fine in my machine .When i am going to deploy the application on other server it will gives the error like this

javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=us-ascii

with other 100 lines of error.

I need help from any one.

Thanks in advance.


Re: not working java mail application in other machine.

Posted By:   Ashu_Jadhav  
Posted On:   Friday, January 5, 2007 04:05 AM

I also faced this problem so i used ByteArrayDataSource to set content type you will not find the class in the java mail folder if u require source here it is just copy it in your project folder and complie it.After that make some changes in your mailsend java file
message.setDataHandler(new DataHandler(new
ByteArrayDataSource(strurmessagehtml.toString(), "text/html")));

// Send message

ByteArrayDataSource Souce code

import java.io.*;
import javax.activation.*;

public class ByteArrayDataSource implements DataSource {
private byte[] data; // data
private String type; // content-type

/* Create a DataSource from an input stream */
public ByteArrayDataSource(InputStream is, String type) {
this.type = type;
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
int ch;

while ((ch = is.read()) != -1)
data = os.toByteArray();

} catch (IOException ioex) { }

/* Create a DataSource from a byte array */
public ByteArrayDataSource(byte[] data, String type) {
this.data = data;
this.type = type;

/* Create a DataSource from a String */
public ByteArrayDataSource(String data, String type) {
try {
// Assumption that the string contains only ASCII
// characters! Otherwise just pass a charset into this
// constructor and use it in getBytes()
this.data = data.getBytes("iso-8859-1");
} catch (UnsupportedEncodingException uex) { }
this.type = type;

public InputStream getInputStream() throws IOException {
if (data == null)
throw new IOException("no data");
return new ByteArrayInputStream(data);

public OutputStream getOutputStream() throws IOException {
throw new IOException("cannot do this");

public String getContentType() {
return type;

public String getName() {
return "dummy";
About | Sitemap | Contact