Question

Hello i am able to send a mail from my web application. But the problem here is am able to send only one line of message ie

I want to send a message saying:

Your username is : xxxx Your PassWord is: xxx

     Message message = new MimeMessage(session);
                    message.setFrom(new InternetAddress("xxx@gmail.com"));
                    message.setRecipients(Message.RecipientType.TO,
                        InternetAddress.parse(Class.email));
                    message.setSubject("Registration Confirmation with SK Business Group");
                    message.setContent("<h1>Congratulations on successfully registering with us</h1><h2>Your user name is:</h2>" +Class.uname ,  
                            "text/html");
message.setContent("<h2>Your password is:</h2>" +Class.pass ,  
                            "text/html");

                    Transport.send(message);

But when the mail reaches the recipient only username is displayed...

I want both username and password to be displayed. Some one please help me resolving this..Thanks in advance.

Note : Uname and pass are static variables of a class which is got by its classname.

Was it helpful?

Solution

You are setting the content twice, add both lines in the same call to setContent:

message.setContent("<h1>Congratulations on successfully registering with us</h1>"
    + "<h2>Your user name is:</h2>" +ApproveDAO.uname
    + "<h2>Your password is:</h2>" +ApproveDAO.pass, "text/html");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top