Send an email with Arabic characters using SMTPsvg.Mailer
I am trying to send an email with Arabic charcters using SMTPsvg.Mailer. Is it possible?
Here is my code:
Code:
set mailObj = Server.CreateObject("SMTPsvg.Mailer")
'set mailObj = Server.CreateObject("Persits.MailSender")
mailObj.FromAddress = fromAddr
mailObj.RemoteHost = smtpServer
mailObj.ReplyTo = fromAddr
mailObj.AddRecipient "", Trim(sToAddress)
MailObj.CustomCharSet = "windows-1256"
mailObj.Subject = sSubject
'mailObj.ContentType = "text/html"
mailObj.BodyText = sBody
if not mailObj.SendMail then
SendMail = "Email send failed: " & mailObj.Response & "."
end if
I have set the customCharSet to "windows-1256" (Arabic), but when I check the email on the recieving end, it just comes out as a bunch of ?????? symbols.
Doing a google search, I find that a lot of people seem to be using CDONTS.Newmail instead of SMTPsvg.Mailer for sending emails with Arabic, is this because it can't be done using SMTPsvg.Mailer? If so, to use CDONTS, do i need to have something installed on the server?
I have worked out a solution using CDO, tested it and it works, here it is:
Code:
on error resume next
dim mail
set mail=server.createobject("CDO.Message")
mail.from=fromAddr
mail.to=sToAddress
mail.subject=sSubject
mail.bodypart.charset="utf-8"
mail.htmlbody=sBody
mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")=smtpServer
'Server port
mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
mail.Configuration.Fields.Update
mail.send()
set mail=nothing
Bookmarks