How can I change the content of my message!

I get a message of type "application/x-pkcs7-mime", I use the method object o= msg.getContent() and I get a java object o, o is a instance of InputStream, then I read this InputStream to get the content text encrypted of the message and make some modifications on the content, at last I get a new String which is the content that I want to use to replace the old one! How can I write the new String into my message as the content itself?

I tried to use:

DataHandler dataTransencrypted =new DataHandler(text_clair,msg.getContentType());

msg.setDataHandler(dataTransencrypted);

msg.saveChanges();

But when I do

msg.write to(System.out)

I encounted the exceptions like:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/x-pkcs7-mime;

smime-type=enveloped-data;

name="smime.p7m"

Anyone can help me? Thank you very much!

Message was edited by:

xuetao

[1010 byte] By [xuetaoa] at [2007-10-3 5:12:59]
# 1

After you decrypt the message content, it's no longer of type

"application/x-pkcs7-mime". It's probably of type "text/plain"

(or some other type specified by some other header in the

encrypted data). You need to use the correct type when

creating the new DataHandler. And if the data is of a type

that JavaMail doesn't directly support, you'll want to create

the new DataHandler using a ByteArrayDataSource to

represent the data.

bshannona at 2007-7-14 23:19:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks a lot! I've resolved my problem!
xuetaoa at 2007-7-14 23:19:25 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...