Solved

Jmail and Chinese Characters

Posted on 2006-06-27
14
821 Views
Last Modified: 2008-01-09
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.EnableCharsetTranslation = 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.
0
Comment
Question by:slamhound
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 16998811
I dun think there's any problem with your email code.

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???
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 16999082
Or try an easy way

use server.HTMLEncode()

Hehe =)
0
 
LVL 10

Author Comment

by:slamhound
ID: 17005625
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&#26222;&#23527;&#35910;&#37292;&#25903;&#31481;&#20733;&#20720;&#20689;&#20706;&#20733;&#20719;</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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17006315
0
 
LVL 10

Author Comment

by:slamhound
ID: 17006889
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.
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17006895
jmail.HTMLBody = server.HTMLEncode(Html)

this should help, as this work for me. =)
0
 
LVL 10

Author Comment

by:slamhound
ID: 17006914
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.
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17006924
How you obtain the html ?
mind to paste the code here?
0
 
LVL 10

Author Comment

by:slamhound
ID: 17007084
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(Server.MapPath("/ClientX/xsl/order_email.xsl"))
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17015428
  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
0
 
LVL 11

Accepted Solution

by:
kelvinwkw earned 500 total points
ID: 17015451
  Function c2u(CnText)
      For zzzz = 1 to Len(CnText)
        c = Mid(CnText, zzzz, 1)
        if ascw(c) > 122 and ascw(c) < 33  then
           c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
        else
           c2u = c2u & c
        end if
     Next
   End Function


Oops sorry miss out sojething =(


0
 
LVL 10

Author Comment

by:slamhound
ID: 17029228
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.
0
 
LVL 10

Author Comment

by:slamhound
ID: 17029376
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!!!
0
 
LVL 11

Expert Comment

by:kelvinwkw
ID: 17029840
Welcome =)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question