slamhound
asked on
Jmail and Chinese Characters
I'm taking Chinese orders using an ASP shopping cart. The Chinese characters store well in the DB and I can retrieve them well, but as soon as I go to email an order confirmation, the Chinese characters turn out to be question marks.
How can I get Jmail to send with the Chinese caracters?
Set jmail = Server.CreateObject("JMail .Message")
jmail.ContentType = "text/html"
jmail.Charset = "utf-8"
jmail.EnableCharsetTransla tion = false
jmail.ISOEncodeHeaders = false
jmail.From = "orders@clientx.biz"
jmail.FromName = "Orders"
jmail.AddRecipient "orders@clientx.biz"
jmail.Subject = "A New Website Order" & strTempSub
jmail.HTMLBody = Html ' I dump what's in this Html variable to the screen and the Chinese characters look fine
jmail.Send( "smtp-au.server-mail.com" )
This code has ALL the options I could think of but started out with just the simple basic ones. Either simple or complex got me no-where.
How can I get Jmail to send with the Chinese caracters?
Set jmail = Server.CreateObject("JMail
jmail.ContentType = "text/html"
jmail.Charset = "utf-8"
jmail.EnableCharsetTransla
jmail.ISOEncodeHeaders = false
jmail.From = "orders@clientx.biz"
jmail.FromName = "Orders"
jmail.AddRecipient "orders@clientx.biz"
jmail.Subject = "A New Website Order" & strTempSub
jmail.HTMLBody = Html ' I dump what's in this Html variable to the screen and the Chinese characters look fine
jmail.Send( "smtp-au.server-mail.com" )
This code has ALL the options I could think of but started out with just the simple basic ones. Either simple or complex got me no-where.
Or try an easy way
use server.HTMLEncode()
Hehe =)
use server.HTMLEncode()
Hehe =)
ASKER
We're getting a bit closer in that the Chinese characters are displaying. BUT, so are all of the HTML tags.
jmail.HTMLBody = server.HTMLEncode(Html)
Gives me:
<tr> <td align="left" valign="top"> Address 2 </td> <td align="left" valign="top">Chinese Chars Here普寧ง 0;醬 支&# 31481; 733;࠘ 0;僑 僢&# 20733; 719;</td> </tr> <tr> <td align="left" valign="top"> Suburb/City/Town </td> <td align="left" valign="top">JUST TESTING</td> </tr> <tr> <td align="left" valign="top"> State </td>
Instead of the HTML tags being displayed properly to get the nice formatting I used to have.
jmail.HTMLBody = server.HTMLEncode(Html)
Gives me:
<tr> <td align="left" valign="top"> Address 2 </td> <td align="left" valign="top">Chinese Chars Here普寧ง
Instead of the HTML tags being displayed properly to get the nice formatting I used to have.
ASKER
I've tested and verified that saving to, and retriving from, the database is not a problem. The database is storing the characters OK. The problem is when I come to email them.
jmail.HTMLBody = server.HTMLEncode(Html)
this should help, as this work for me. =)
this should help, as this work for me. =)
ASKER
Please see above. Making this change caused the characters to appear but also all of the HTML formatting tags were shown in the email also.
How you obtain the html ?
mind to paste the code here?
mind to paste the code here?
ASKER
There are around 180 lines of code excluding the XSL pages so I can't post it all here. The system stores everything for an order in XSL whether it's from session variables or database reads. We then splice this date with the XSL file useing:
Html = oTransformer.Transform(Ser ver.MapPat h("/Client X/xsl/orde r_email.xs l"))
Html = oTransformer.Transform(Ser
Function c2u(CnText)
For zzzz = 1 to Len(CnText)
c = Mid(CnText, zzzz, 1)
if ascw(c) > 254 then
c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
else
c2u = c2u & c
end if
Try this function
For zzzz = 1 to Len(CnText)
c = Mid(CnText, zzzz, 1)
if ascw(c) > 254 then
c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
else
c2u = c2u & c
end if
Try this function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've included your function but the email still comes out with questionmarks where the Chinese characters should be. :(
When I view the source of the email there are physical question marks and no &#x codes.
When I view the source of the email there are physical question marks and no &#x codes.
ASKER
It works!
Changin "ascw(c) > 122 and ascw(c) < 33" to "ascw(c) > 122 or ascw(c) < 33" let me see what you were trying to do. When I changed it to > 192 only then it left all the HTML formatting but changed any character above the standard English alphabet.
Thank you very much!!!
Changin "ascw(c) > 122 and ascw(c) < 33" to "ascw(c) > 122 or ascw(c) < 33" let me see what you were trying to do. When I changed it to > 192 only then it left all the HTML formatting but changed any character above the standard English alphabet.
Thank you very much!!!
Welcome =)
Try to use this function
Function c2u(CnText)
For zzzz = 1 to Len(CnText)
c = Mid(CnText, zzzz, 1)
c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
next
End Function
By the way may i know how you insert utf-8 chinese character into DB???