Convert Arabic text to HTML Code characters

前端 未结 2 548
鱼传尺愫
鱼传尺愫 2021-01-20 16:08

I\'m trying to send an email containing Arabic text, my problem is that when I add the Arabic text to the email, it changes it to random letters (to do with the character en

相关标签:
2条回答
  • 2021-01-20 16:45

    Leave the HTML escapes (ex ס) in, and turn the e-mail to HTML by setting ContentType to text/html

    'Create mailer
    mailer.ContentType = "text/html"
    'User mailer
    

    To convert the unicode to HTML escapes you can use the built in function HTMLEncode.

    mailer.BodyText =  Server.HTMLEncode(body)
    

    Note: Your viewer will need to have the appropriate set of glyphs installed.

    0 讨论(0)
  • Have you tried setting the encoding type in the HTML header?

    Add the following to the <head> section of your HTML:

    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    

    This should make your arabic (and other non-ascii) characters render properly.

    That said, it's important to note that when sending HTML emails, you will always have an issue because different email clients in common use have wildly different capabilities -- even more so than browsers.

    One person may open the email in a current version of Outlook, another in a ten-year-old copy. Someone else may use some version of Thunderbird, and many others will use a webmail client like Hotmail, Yahoo, Gmail, or countless others. There may even be people who still have their email set to show text mode emails rather than HTML.

    You probably have no control over any of that, so its important to be sure you've tested in a variety of email clients. That said, given that you're sending Arabic text, it can be assumed that most of your recipients will be using an email client that can render Arabic successfully, so hopefully that fact alone should mitigate the worst of this issue for you.

    0 讨论(0)
提交回复
热议问题