| | |
How to specify character encoding in JavaMail?
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 3
Reputation:
Solved Threads: 0
Hi, I successfully send email with the following code in English. However, if the message and the subject title are in other characters, everything becomes question marks and the subject title says something like ...ANSI...3F=3F=3F...
How do I set the character encoding to utf-8, for example? Thanks.
I have this in the jsp:
How do I set the character encoding to utf-8, for example? Thanks.
I have this in the jsp:
html Syntax (Toggle Plain Text)
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="en-us"> <title>Emailing</title> <link href="/styles.css" rel="stylesheet" type="text/css"/> </head>
java Syntax (Toggle Plain Text)
try { Properties props = new Properties(); Session sendMailSession; Transport transport; sendMailSession = Session.getInstance(props, null); props.put("mail.smtp.host", SMTP_CLIENT); Message newMessage = new MimeMessage(sendMailSession); newMessage.setFrom(new InternetAddress(EMAIL_FROM)); newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(strEmail)); newMessage.setSubject(SUBJECT); newMessage.setSentDate(new Date()); strMsg = "Dear " + RS.getString("FIRST") + " " + RS.getString("LAST") + ","; strMsg += "\n\n"; strMsg += [MESSAGE IN CHARACTERS OTHER THAN ASCII]; newMessage.setText(strMsg); transport = sendMailSession.getTransport("smtp"); transport.send(newMessage); } catch(MessagingException m) { ... }
![]() |
Other Threads in the JSP Forum
- Previous Thread: Problems with List and ArrayList
- Next Thread: Help, Please!!! Can't Send Mail with SmtpClient
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web





