How do you send two body parts as part of the main message?

I am attempting to send two text lines as part of the main (inline) mail message. The result is a main message using the first test message and an attachment for the second. How do I get both lines of text into the main message? I am using the following code fragement.

String d_email = from,

d_password = pword,

//d_host = "smtp.gmail.com",

d_host = host,

//d_port = "465",

d_port = port,

m_to = to,

m_subject = subject,

m_text ="test";

Properties props =new Properties();

props.put("mail.smtp.user", d_email);

props.put("mail.smtp.host", d_host);

props.put("mail.smtp.port", d_port);

props.put("mail.smtp.starttls.enable","true");

props.put("mail.smtp.auth","true");

//props.put("mail.smtp.debug", "true");

props.put("mail.smtp.socketFactory.port", d_port);

props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");

props.put("mail.smtp.socketFactory.fallback","false");

SecurityManager security = System.getSecurityManager();

try

{

Authenticator auth =new SmtpAuthenticator(from, pword);

Session session = Session.getInstance(props, auth);

//session.setDebug(true);

MimeMessage msg =new MimeMessage(session);

msg.setSubject(m_subject);

msg.setFrom(new InternetAddress(d_email));

msg.addRecipient(Message.RecipientType.TO,new InternetAddress(m_to));

MimeMultipart mp =new MimeMultipart("related");

MimeBodyPart mbp1 =new MimeBodyPart();

mbp1.setText(m_text);

mbp1.setDisposition(Part.INLINE);

mp.addBodyPart(mbp1);

MimeBodyPart mbp2 =new MimeBodyPart();

mbp2.setText("test2");

mbp2.setDisposition(Part.INLINE);

mp.addBodyPart(mbp2);

msg.setContent(mp);

Transport.send(msg);

}

catch (Exception mex)

{

mex.printStackTrace();

}

[2867 byte] By [sandyg9000a] at [2007-11-27 1:23:43]
# 1

Combine the two strings into one string and set that string as

the content of the first body part. Of course, you don't need

a multipart message to do this so if that's all you're including

in your message make it much simpler and just create a

single part plain text message.

bshannona at 2007-7-12 0:13:44 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thank you for your fast response.What I am attempting to do is take baby steps. What I really want to do is to have multiple images combined in the main part of a mail message.I have the code that enables me to print the images a page at a time. What I would like to do is add an image for each page. That is why i am testing adding separate parts to the main part. Is this not a good way to test this facility.

sandyg9000a at 2007-7-12 0:13:44 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

There's no way to guarantee that the parts of a multipart message

will be concatenated and displayed as a coherent single document.

Your best bet is to create a multipart/related message with a main

text/html part that references the other parts of the message. You

can combine the other parts of the message together into a single

displayable document using the capabilities of html.

bshannona at 2007-7-12 0:13:44 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...