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 encoding of the email - which I can't change).
Is there a built in function or a custom function I can use to convert the Arabic to HTML Codes (ا) so it will then appear in my HTML email?
Have you tried setting the encoding type in the HTML header?
Add the following to the
<head>
section of your HTML: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.
Leave the HTML escapes (ex
ס
) in, and turn the e-mail to HTML by settingContentType
totext/html
To convert the unicode to HTML escapes you can use the built in function HTMLEncode.
Note: Your viewer will need to have the appropriate set of glyphs installed.