[英]Sending message through java mail
Hello i am able to send a mail from my web application. 您好,我能够从我的Web应用程序发送邮件。 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 您的用户名是:xxxx您的密码是: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. 注意:Uname和pass是通过其类名获取的类的静态变量。
You are setting the content twice, add both lines in the same call to setContent
: 您要设置两次内容,在同一调用
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.