Here's the code for the ByteArrayDataSource

 1:import javax.mail.*;
 2:import javax.mail.internet.*;
 3://import atg.service.email.*;
 4:import java.util.Properties;
 5:import java.util.Date;
 6:import javax.activation.*;
 7:
 8:
 9:public class MailTest {
10:
11:    public static void main(String[] args) {
12:        try{
13:            //CREATE THE MESSAGE
14:            Properties props = System.getProperties();
15:            props.put("mail.smtp.host", "mail.cadvision.com");
16:
17:            //standard Mail API
18:            Session session = Session.getDefaultInstance(props, null);
19:            session.setDebug(true);
20:            Message msg = new MimeMessage( session );
21:            msg.setFrom( new InternetAddress( "schuldar@yahoo.com" ) );
22:            msg.setRecipient( Message.RecipientType.TO, new InternetAddress( "schuldar@cadvision.com" ) );
23:            msg.setDataHandler(new DataHandler(
24:                new ByteArrayDataSource("This is <b>html</b> text <a href=www.cadvision.com/schuldar>Hello</a>", "text/html")));
25:
26:            //ATG Dynamo Utility Classes
27:            //Message msg = MimeMessageUtils.createMessage();
28:            //MimeMessageUtils.setFrom( msg, "schuldar@cadvision.com");
29:            //MimeMessageUtils.setRecipient( msg, Message.RecipientType.TO, "schuldar@cadvision.com");
30:
31:            //Set some message properties
32:            msg.setSubject( "This is a test");
33:            msg.setHeader("X-Mailer", "msgsend");
34:            msg.setSentDate(new Date());
35:
36:            //Set the message content (Dynamo)
37:            //ContentPart[] content = {
38:            //     new ContentPart( "This is <b>html</b> text", "text/html" ) };
39:            //MimeMessageUtils.setContent( msg, content );
40:
41:            //send the message
42:            Transport.send( msg );
43:
44:
45:        }catch( Exception e){
46:            e.printStackTrace();
47:        }
48:    }
49:}
1