Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP : Email Body UTF-8 Problem

Status
Not open for further replies.

ZeeHashmi

MIS
Dec 26, 2004
2
PK
Hi,

Well I am a PHP Programmer, and I am coding in Classic ASP for some reason. I am stuck at a place.
My script need to send an email that will have Swedish Characters.
I have below code, the Subject is fine however the email body shows ?? in place of all the Swedish characters. Like this: Best??llning Ovriga ??nskem??l

Please help me !
Regards
Z

Code:
<%@Language = VBScript Codepage = 65001 %>
<%
dim objMail 
Set objMail = Server.CreateObject("CDO.Message") 

dim smtpServer, yourEmail, yourPassword
smtpServer = "127.0.0.1"
yourEmail = "no_reply@mydomain.com"     
yourPassword = "my_password"
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = smtpServer
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = 1
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25 
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = true
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = yourEmail
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = yourPassword
objMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60

objMail.BodyPart.Charset = "utf-8"
objMail.Configuration.Fields.Update 
objMail.Subject="Beställning Ovriga önskemål"
objMail.htmlBody = "<strong>Beställning Ovriga önskemål</strong>"
objMail.htmlBodyPart.Charset = "utf-8"
objMail.from = yourEmail
objMail.to = "recipient@some_mail.com"
objMail.Send  
%>
 
I don't know the answer, but since your code is pretty much all vbscript, I recommend also posting this question in the vbscript forum: forum329
 
Hi Z,

I found the solution here:
Try
Code:
objCDOMailer.TextBodyPart.Charset = "utf-8"

instead of

Code:
objCDOMailer.BodyPart.Charset = "utf-8" 
objCDOMailer.HTMLBodyPart.Charset = "utf-8"

Obviously, the encoding problem does stem from TextBodyPart, so even if you set the htmlbody encoding correctly, it won't work since the problem is higher up in the hierarchy.

Good luck!
MakeItSo

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Unfortunately not, thats not the solution. My email is based on HTML therefore I cant use TextBodyPart.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top