Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Classic ASP Error

Posted on 2013-01-18
11
1,036 Views
Last Modified: 2013-01-23
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
Comment
Question by:Manoj Patil
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38792654
Try removing the semi-colons from lines 120 and 122
0
 
LVL 6

Expert Comment

by:esolve
ID: 38792670
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
 
LVL 19

Author Comment

by:Manoj Patil
ID: 38792684
Both the solutions were not working !!
Getting same error
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 76

Expert Comment

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

Open in new window

0
 
LVL 6

Expert Comment

by:esolve
ID: 38792733
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
 
LVL 19

Author Comment

by:Manoj Patil
ID: 38792746
No luck !!
Now getting

Microsoft VBScript runtime error '800a01b6'

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

/ThankYou.asp, line 113
0
 
LVL 19

Author Comment

by:Manoj Patil
ID: 38792756
This code was working properly and site is also working as it is.
But unfortunately error come without changing anything
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38793324
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
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 0 total points
ID: 38794126
I found my solutions
See this link.
http://support.reliablesite.net/KB/a6/sending-emails-from-classic-asp.aspx
It helps someone.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38794333
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
 
LVL 19

Author Closing Comment

by:Manoj Patil
ID: 38809144
Solve my problem
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question