JAVAMAIL FORMAT/SORT EMAILED FIELDS

Hi,

I am suing the following code to send variable numbers of fields from a form. The strings are sent correctly but in the wrong order - how do I get them to list as the original form. Also how do I send HTML formatting in the email (e.g.

's):

At the moment I get something like:

Some text!!!

adrian@protocolwebdesign.com

2

?br>

1

BOOK ORDER

?br>Send Order

Mr

Some text!!!

?br>Mastercard

06

01

Wanting to get something like:

EMail:adrian@protocolwebdesign.com

Book1: bookname1

Book2: bookname 2

Card Type: Mastercardetc....

CODE IS:

Properties props = new Properties();

props.put("mail.countrychoicecookers.com", "mail.wanadoo.co.uk");

Session s = Session.getInstance(props,null);

MimeMessage message = new MimeMessage(s);

InternetAddress from = new InternetAddress("info@countrychoicecookers.com");

message.setFrom(from);

String toAddress = request.getParameter("to");

InternetAddress to = new InternetAddress(toAddress);

message.addRecipient(Message.RecipientType.TO, to);

String subject = request.getParameter("subject");

message.setSubject(subject);

String text = request.getParameter("text");

Enumeration paramNames = request.getParameterNames();

while(paramNames.hasMoreElements()) {

String paramName = (String)paramNames.nextElement();

out.println("Parameter Name:" + paramName + "

");

String[] paramValues = request.getParameterValues(paramName);

out.println("Value:"+paramValues+"

");

for(int i=0; i < paramValues.length; i++){

text+="

";

text+=paramValues ;

}

}

message.setText(text);

Transport.send(message);

NOTE: THERE IS A [ i ] after text+=paramValues above - for some bizarre reason it dissapears when i preview this message!!!

[1979 byte] By [adrian@protocola] at [2007-10-3 4:33:22]
# 1

This isn't really a javamail issue, but......

If you knew what the non-book fields are, you could directly access those from the request object without iterating through all of your data.

If you name the book fields correctly (aka, they all start with "Book") you could easily throw in a if/then to only include those when you iterate the whol request object.

--

travis(at)overwrittenstack.com

travis_fergusona at 2007-7-14 22:36:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...