Haneef Puttur

How to send Arabic email using CDOSYS in classic ASP

I have been trying this for a couple of weeks now and last night i have found a way that it could be done quite easily in classic ASP. Sending emails using the SMTP server in windows is quite easy, however i have been trying to do this for a client where he needs to send emails from the website using arabic characters when users make reservations from the website. After completing this page using a typical ASP page, i figured out that the arabic characters are displayed as ????? (question marks)..

 

As usual, i tried to solve this problem by searching the google to find a solution for this. I found that many people have faced the same problem as me, but couldn’t find a solution. Then i tried to search the Microsoft website to find the members of the “CDO.Message” object. And finally i figured out that there is a property to change the charset of the message body.. and when i changed this charset to “utf-8” it worked!!

 

 

Here’s the source code of the ASP file, so that anyone who faces this problem might find this useful..

 

 

set cdoMessage = Server.CreateObject(“CDO.Message”)

set cdoConfig = Server.CreateObject(“CDO.Configuration”)

cdoConfig.Fields(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

cdoConfig.Fields(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “127.0.0.1”

cdoConfig.Fields.Update

set cdoMessage.Configuration = cdoConfig

cdoMessage.BodyPart.Charset = “utf-8”

cdoMessage.From = “from@mail.com”

cdoMessage.To = “recipients@mail.com”

cdoMessage.Subject = “Arabic Email usin SMTP – CDOSYS”

cdoMessage.HtmlBody = “مرحبا بك فى المالديف

cdoMessage.Send

set cdoMessage = Nothing

set cdoConfig = Nothing

.

Exit mobile version