?
Solved

Jmail and Chinese Characters

Posted on 2006-06-27
14
Medium Priority
?
827 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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/…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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