Solved

Jmail and Chinese Characters

Posted on 2006-06-27
14
798 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now