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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP / Jmail generating gibberish instead of Hebrew

Status
Not open for further replies.

TribeMan

Programmer
Nov 16, 2009
22
IL
The code below takes form variables (lines 3-12), runs some validation routines (lines 14-48), and then uses Jmail to send a response (lines 50-81). If the user enters English in the form, then everything works fine: I receive an email in English.

However, if the user enters Hebrew characters, the Hebrew text comes out complete gibberish.

NOTE: The validation routine generates Hebrew messages which display perfectly on the form. It's just the email that won't display Hebrew chars properly.

What am I doing wrong? I've tried a whole lot of tricks such as adding: Jmail.Charset = "windows-1255".

BTW, my header contains the code: <META HTTP-EQUIV="Content-Type" content="text/html; charset=windows-1255">

Code:
<%
'Option Explicit
dim strName, strEmail, strEmailConfirm, strMessage, optTopic, strTelephone 

	strName = Request.Form("name")  
	strEmail = Request.Form("email")
	strEmailConfirm = Request.Form("emailConfirm")
	strMessage = Request.Form("message")
	strTelephone = Request.Form("telephone")
	optTopic = Request.Form("topic").Item 

	isError = 0
	strErrText = ""
		
		if strName = "" then
			strErrText = strErrText & ">?? ???? ?? ???<br>"
			isError = isError +1
		end if
			
		if strEmail = "" or len(strEmail) < 5 or instr(strEmail,"@") = 0 or instr(strEmail,".") = 0 then 
			strErrText = strErrText & ">?? ????? ????? ???? ???????? ???<br>"
			isError = isError +1
		end if
		
		if strEmail <> strEmailConfirm then
			strErrText = strErrText & ">?????? ????? ???????? ???? ??????<br>"
			isError = isError +1
		end if
		
		if optTopic = "" then
			strErrText = strErrText & ">?? ????? ???? ??????<br>"
			isError = isError +1
		end if

		if strMessage = "" then
			strErrText = strErrText & ">?? ????? ?? ??????"
			isError = isError +1
		end if
		
		If IsError > 0 Then
			Response.Redirect "contact.asp?" & Request.Form & "&strErrText=" & Server.URLEncode(strErrText)
		End If

		If len(trim(strTelephone)) <5 then
		 	strTelephone = "not submitted"
		End If
		
' -- begin email send process --

	Dim JMail, mailbody 

	mailbody = "<table border='0'><tr><td colspan='2'><b>To:</b> Gold 'n Pearl Administrator,</td></tr>"
	mailbody = mailbody & "<tr><td colspan='2'><br>The following was submitted by a Gold 'n Pearl viewer using the 'Contact Us' form:<br><br></td></tr>"
	mailbody = mailbody & "<tr><td><b>Viewer Name:</b></td><td>" & Trim(strName) & "</td></tr>"
	mailbody = mailbody & "<tr><td><b>Email: </b></td><td>" & Trim(strEmail) & "</td></tr>"
	mailbody = mailbody & "<tr><td><b>Topic: </b></td><td>" & optTopic & "</td></tr>"
	mailbody = mailbody & "<tr><td><b>Telephone: </b></td><td>" & Trim(strTelephone) & "</td></tr>"
	mailbody = mailbody & "<tr><td><b>Message: </b></td><td>" & Trim(strMessage) & "</td></tr>"
	mailbody = mailbody & "<tr><td colspan='2'><br><br><b>From:</b> Gold 'n Pearl Autoresponder</td></tr>"

	On Error Resume Next

	email_SendJmail = true
	strBody = email_wrapBody(strBody)
	
	Set JMail = Server.CreateObject("JMail.Message")
    
    JMail.Charset = "utf-8"
    JMail.MailServerUserName = const_ServerUserName
	JMail.MailServerPassword = const_ServerPassword 
'	JMail.From = const_From
'	JMail.ReplyTo = const_replyTo
'	JMail.FromName = const_fromName-->
   	JMail.From = strEmail
	JMail.ReplyTo = strEmail
	JMail.FromName = strName
	JMail.Subject = "Contact request from Gold 'n Pearl viewer"
	JMail.AddRecipient const_recipient,const_fromName
'	JMail.AddRecipientBCC const_Email_EmailBCCAddress
	JMail.HTMLBody = mailbody

	JMail.Send(const_SMTPServer)

	Response.Redirect "contactThanks.asp"

  If Err.number <> 0 Then
	email_SendJmail = false
	Response.Redirect "contactError.asp"
  End If
  	
	Set JMail = Nothing
%>
 
Is the asp file saved as utf-8? If you save the file as utf-8, then set it as utf-8. It should be saved as the same type as the asp file.
 
Found the problem...

The form page had the <META> tag: <META HTTP-EQUIV="Content-Type" content="text/html; charset=windows-1255">

However, the processing page (with code as shown in my original posting) did not.

I simply added the <META> tag to the above code, and voilá!

Thanks anyway.
 
To make it the same, set

response.CharSet = "windows-1255
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top