Solved

Classic ASP Error

Posted on 2013-01-18
11
1,029 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now