I'm having trouble with the commons email. I'm setting all of the
attributes and when I process the message it gets sent but for some
reason the message body is empty.

 

I'm processing my messages through an Exchange 2003 server.

 

This is what I'm using and I've verified that the message is getting set
in my logs. Any insight would be greatly appreciated.

 

String email = new String();

                        String to = new String();

                        String emailFrom = new String();

                        String emailFromName = new String();

                        try {

                                    // Get email attributes from web.xml
file.

                                    ctx = new InitialContext();

                                    mailHost =
(String)ctx.lookup("java:comp/env/mailHost");

                                    // Email Address.

                                    emailFrom =
(String)ctx.lookup("java:comp/env/emailFrom");

                                    // Email Address Display Name.

                                    emailFromName =
(String)ctx.lookup("java:comp/env/emailFromName");

                                    // Set the messaging configuration
information.

                                    HtmlEmail htmlEmail = new
HtmlEmail();

                                    htmlEmail.setHostName(mailHost);

                                    // Customer email information.

                                    email = i.getCustomer().getEmail();

                                    to = i.getCustomer().getFirstName()
+ " " + i.getCustomer().getLastName();

                                    htmlEmail.addTo(email, to);

                                    // CC business email information.

                                    htmlEmail.addCc(emailFrom,
emailFromName);

                                    // From business email information.

                                    htmlEmail.setFrom(emailFrom,
emailFromName);

                                    htmlEmail.setSubject("Mini Moon
Order");

                                    String msg = formatInvoiceOrder(i);

                                    // Set the html message

                                    htmlEmail.setHtmlMsg("<html>" + msg
+ "</html>");

                                    // Set the alternative message

                                    //htmlEmail.setTextMsg("Your email
client does not support HTML messages.");

                                    htmlEmail.setTextMsg(msg);

                                    // Send the email

 
//htmlEmail.setAuthentication("********", "**********");

                                    htmlEmail.send();

                        }

Reply via email to