Sad... I have transcoded it too. But I still cannot. Experts, help me ....
<% @ Page contenttype = "text/html; charset = gb2312" %>
<% @ Page import = "Java. util. *, javax. Mail. *" %>
<% @ Page import = "javax. Mail. Internet. *, javax. Mail. *" %>
<%!
Public String codetostring (string Str ){
String Ss = STR;
Try {
Byte tempb [] = ss. getbytes ("ISO-8859-1 ");
Ss = new string (tempb, "gb2312 ");
Return SS;
}
Catch (exception e ){
Return SS;
}
}
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
</Head>
<Body>
<%
Try {
// String to_mail = codetostring (request. getparameter (""));
// String to_titile = codetostring (request. getparameter ("title "));
// String to_content = codetostring (request. getparameter ("content "));
String to_mail = codetostring ("331062104@qq.com"); // recipient
String to_title = codetostring ("mail title ");
String to_content = codetostring ("email content ");
// Sun. Misc. base64encoder ENC = new sun. Misc. base64encoder ();
// Message. setsubject ("=? Gb2312? B? "+ Enc. encode () + "? = ");
Properties props = new properties ();
Props. Put ("mail. SMTP. Host", "smtp.126.com ");
Props. Put ("mail. SMTP. Auth", true );
Session S = session. getinstance (props );
S. setdebug (true );
Mimemessage message = new mimemessage (s );
Internetaddress from = new internetaddress ("mianye349896094@126.com"); // sender's mailbox
Internetaddress to = new internetaddress (to_mail );
Message. setfrom (from );
Message. setrecipient (message. recipienttype. To, );
//
Message. setsubject (to_title );
Message. settext (to_content );
Message. setsentdate (new date ());
Message. savechanges ();
Transport transport = S. gettransport ("SMTP ");
Transport. Connect ("smtp.126.com", "mianye349896094@126.com", "password ");
Transport. sendmessage (message, message. getallrecipients ());
Transport. Close ();
%>
<Div> sent successfully! </Div>
<%
}
Catch (exception e ){
Out. println ("failed to send ");
}
%>
</Body>
</Html>