Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1050
  • Last Modified:

Classic ASP Error

This is my code
	
	<%
	'Dim Conn ,strConn
	'set Conn = Server.CreateObject("ADODB.Connection")
	'strConn = "DRIVER={SQL Server};Server=209.61.240.444;UID=pharma_db;PWD=pwd;database=otpharma;"
	'Conn.open strConn
	
	name 				= Replace(request.form("name"),"'","`")
	company			= Replace(request.form("company"),"'","`")
	country	 			= Replace(request.form("country"),"'","`")
	city 				        = Replace(request.form("city"),"'","`")
	state 				= Replace(request.form("state"),"'","`")
	email 				= Replace(request.form("email"),"'","`")
	intersted 			= Replace(request.form("intersted"),"'","`")
	phone 				= Replace(request.form("telephone"),"'","`")
	mobile	 			= Replace(request.form("mobile"),"'","`")
	comments 			= Replace(request.form("comments"),"'","`")
	campaign   			= Replace(Session("Campaign"),"'","`")
	adword	   			= Replace(Session("Adword"),"'","`")
	keyword	   			= Replace(Session("Keyword"),"'","`")
	referer 	 		= Replace(Session("Referer"),"'","`")
	ipaddress    		= Request.ServerVariables("REMOTE_ADDR")

	'sSQL = "SELECT * FROM InductionLeadMaster WHERE Name = '" & name & "' and EmailID = '" & email & "'"
	
	'Set rs = Server.CreateObject("ADODB.Recordset")
	'rs.Open sSQL, Conn, 1, 3
	
		'IF rs.EOF THEN
			'sSQL = "INSERT INTO InductionLeadMaster (Name,CompanyName,State,City,Country,EmailID,Interest,ResidenceNo,MobileNo,Comments,Viewed,DateAdded,campaign,adword,keyword,ipaddress,Referer) VALUES "
			'sSQL = sSQL & "('" & name & "','" & company & "','" & state & "','" & city & "','" & country & "','" & email & "','" & intersted & "','" & phone & "','" & mobile & "','" & comments & "',0,getdate(),'" & campaign & "','" & adword & "','" & keyword & "','" & ipaddress & "','" & referer & "')"
		'ELSE	
			'sSQL = "INSERT INTO InductionLeadMaster (Name,CompanyName,State,City,Country,EmailID,Interest,ResidenceNo,MobileNo,Comments,Viewed,DateAdded,campaign,adword,keyword,ipaddress,Referer) VALUES "
			'sSQL = sSQL & "('" & name & "','" & company & "','" & state & "','" & city & "','" & country & "','" & email & "','" & intersted & "','" & phone & "','" & mobile & "','" & comments & "',5,getdate(),'" & campaign & "','" & adword & "','" & keyword & "','" & ipaddress & "','" & referer & "')"
		'END IF
	
	'Set rs = Nothing
	
	'Conn.execute(sSQL)
	'Set Conn = Nothing
	
	SendEmail 'Function call to send email

	Response.redirect("ThankYou.html")
	
	Sub SendEmail()	
		email_body = "<center>"&_
		"<table border=0 cellPadding=6 cellSpacing=0 width='98%'>"&_
		   "<tr>"&_
			"<td width='100%' colspan=3><b><font color=#0018FF face=Verdana size=2>Customer Details</font></b><BR><BR></td>"&_
		  "</tr>"&_
		   "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Name :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& name & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Company Name :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& company & "</font><BR></td>"&_
		  "</tr>"&_
		   "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>City :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& city & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>State :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& state & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Country :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& country & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Email ID :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& email & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Interested in :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& intersted & "</font><BR></td>"&_
		  "</tr>"&_
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Telephone No. :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& phone & "</font><BR></td>"&_
		  "</tr>"&_	
		  "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Mobile No. :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& mobile & "</font><BR></td>"&_
		  "</tr>"&_		  
		   "<tr>"&_
			"<td width='45%'><b><font color=#000000 face=Verdana size=2>Comments :</font></b></td>"&_
			"<td width='2%'></td>"&_
			"<td width='53%' align='left'><font face=Verdana size=2> &nbsp;"& comments & "</font><BR></td>"&_
		  "</tr>"&_
		"</table>"&_
		"</center>"
	          
		  Set Mail = Server.CreateObject("CDO.Message")
		'Set Mail = Server.CreateObject("Persits.MailSender")
		'Mail.Host = "localhost"
		'Mail.Port = 25
		'Mail.Host = "mail.inductioncapsealing.com"
                'Mail.Host = "mail.edmail.in"
		Mail.From = "info@abc.com"
		'Mail.From = "ed@abc.com"
		Mail.IsHTML = True
		'Mail.AddAddress "abc@xyz.in", "ED"		
                Mail.To ="abc@xyz.com"
		'Mail.AddAddress "abc@gmail.com", "ED"
		'Mail.AddBcc "abc@abc.in", "XYZ"
	    Mail.Subject = "Induction Cap Sealing Enquiry"
		Mail.Body = email_body 
               SmtpClient smtp = new SmtpClient("localhost");

        smtp.Credentials = new  NetworkCredential("info@xyz.com", "passws");
		smtp.Send(Mail)
		Set Mail = Nothing
	End Sub
	%>

Open in new window


I am getting below error


Microsoft VBScript compilation error '800a0401'

Expected end of statement

/ThankYou.asp, line 120

SmtpClient smtp = new SmtpClient("localhost");
-------------------------------------------------------^
0
Manoj Patil
Asked:
Manoj Patil
  • 5
  • 2
  • 2
  • +1
1 Solution
 
GrahamSkanCommented:
Try removing the semi-colons from lines 120 and 122
0
 
esolveCommented:
I am a bit rusted with asp 3.0 but I think you have to instantiate it like this:

SmtpClient smtp = new SmtpClient()
smtp.Host = "localhost"
0
 
Manoj PatilSr. Software EngineerAuthor Commented:
Both the solutions were not working !!
Getting same error
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GrahamSkanCommented:
Try using Set and CreateObject
Set smtp = CreateObject(SmtpClient("localhost"))
Set smtp.Credentials = CreateObject(NetworkCredential("info@xyz.com", "passws"))

Open in new window

0
 
esolveCommented:
Not sure if you should use the SmtpClient since this is a .NET object. I think you just need to call send on the Mail object.

I found this worth a try I suppose

Set Mail = Server.CreateObject("CDO.Message")
Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver" ) = "smtphost"

Mail.Send()

And remember if you're using "localhost" it means you have to have SMTP setup on your local IIS. Rather try using the smtp server and credentials of you email settings.
0
 
Manoj PatilSr. Software EngineerAuthor Commented:
No luck !!
Now getting

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Mail.IsHTML'

/ThankYou.asp, line 113
0
 
Manoj PatilSr. Software EngineerAuthor Commented:
This code was working properly and site is also working as it is.
But unfortunately error come without changing anything
0
 
Scott Fell, EE MVEDeveloperCommented:
You are using aspEmail from http://www.aspemail.com/ 

You have a lot of code commented out.  I have never seen these 2 lines for persists aspEmail

SmtpClient smtp = new SmtpClient("localhost");
smtp.Credentials = new  NetworkCredential("info@xyz.com", "passws");

Also in those 2 lines you would not have a semi colon at the end in vbscript

If the first line is supposed to be calling the function  SmtpClient you would simply use
SmtpClient "localhost"
which means you are passing the variable "localhost" to the function SmtpClient.  If that function is supposed to return something then you would use
MyReturnVariable=SmtpClient("localhost")

If this page was working in the past, my guess is there was something else cached that was actually running because this page should have errors.   Or maybe I am just wrong and it should work but your dll for aspEmail needs to be reinstalled.  Or you had this on a trial basis and the trial period ran out.

Basic instructions  http://www.aspemail.com/manual_02.html
<%
' change to address of your own SMTP server
strHost = "mail.elinkisp.com"
If Request("Send") <> "" Then
   Set Mail = Server.CreateObject("Persits.MailSender")
   ' enter valid SMTP host
   Mail.Host = strHost

   Mail.From = Request("From") ' From address
   Mail.FromName = Request("FromName") ' optional
   Mail.AddAddress Request("To")

   ' message subject
   Mail.Subject = Request("Subject")
   ' message body
   Mail.Body = Request("Body")
   strErr = ""
   bSuccess = False
   On Error Resume Next ' catch errors
   Mail.Send	' send message
   If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
   End If
End If
%>

<HTML>
<BODY BGCOLOR="#FFFFFF">
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
<FORM METHOD="POST" ACTION="Simple.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<TR>
   <TD>Host (change as necessary in script):</TD>
   <TD><B><% = strHost %></B></TD>
</TR>
<TR>
   <TD>From (enter sender's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="From"></TD>
</TR>
<TR>
   <TD>FromName (optional, enter sender's name):</TD>
   <TD><INPUT TYPE="TEXT" NAME="FromName"></TD>
</TR>
<TR>
   <TD>To: (enter one recipient's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="To"></TD>
</TR>
<TR>
   <TD>Subject:</TD>
   <TD><INPUT TYPE="TEXT" NAME="Subject"></TD>
</TR>
<TR>
   <TD>Body:</TD>
   <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
   <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Open in new window

0
 
Manoj PatilSr. Software EngineerAuthor Commented:
I found my solutions
See this link.
http://support.reliablesite.net/KB/a6/sending-emails-from-classic-asp.aspx
It helps someone.
0
 
Scott Fell, EE MVEDeveloperCommented:
techChallenger1, I think it could have helped us to know you did not want to use Persists AspEmail  and instead use CDO.  This would have put our efforts in other ways to help you instead of trying to decipher your code as is.  

Also, please request attention to have your original question modified as to not show the location,  username and password of your database.
0
 
Manoj PatilSr. Software EngineerAuthor Commented:
Solve my problem
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now