Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Jmail and Chinese Characters

Posted on 2006-06-27
14
Medium Priority
?
837 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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