Solved

Jmail and Chinese Characters

Posted on 2006-06-27
14
804 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP VB... 7 99
How to remove Duplicates from Generic List in Csharp 5 77
Import csv files to MS SQL 5 73
RegEx Help - open to other simple suggestions 8 39
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 information …
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

16 Experts available now in Live!

Get 1:1 Help Now