sending encrypted files with javamail

Tom Strzemieczny tstrzem@sesame.com
Fri Jul 19 02:49:02 2002


I can send a clearsigned message using javamail, but I don't know how to
send an encrypted message.

Message msg = new MimeMessage(session);
msg.addRecipients(Message.RecipientType.TO, toArray );
msg.setFrom(fromAddress);
msg.setSentDate(new Date());
msg.setSubject(this.subject);
msg.setContent(messageText, contentHeader);
msg.setHeader( "Content-Transfer-Encoding", "base64" );

If  messageText = "the encrypted message" the output does not diplay the

-----BEGIN PGP MESSAGE-----/-----END PGP MESSAGE----- tags,
but rather a sequence of control characters.  It never decrypts, even if
you cut and paste it.  But if you save messageText into a file and
decrypt that, it works.

What do I need to do to get encrypted email messages working properly?
What should be the content-type?
Should this be a multipart email?  Is there anything that must be done
for this to work and have the correct header/footers.?

T