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

Sending emails using asp

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
Hi
I am trying to send emails using asp but I keep getting the following error message. Here is the code that i am using to do it.

Code used and adapted from Beginning ASP 3.0

<!--#include file=&quot;connectionString.asp&quot; --> 'Server side include used to hold the database connection details. Page 481 in Beginning ASP 3.0 book


<!-- METADATA TYPE=&quot;typelib&quot; 'This makes the ADO constants available without having to define them as constants. This information has been taken from page

519 of Beginning ASP 3.0
FILE=&quot;C:\Program Files\Common Files\System\ado\msado15.dll&quot; -->

<%

Dim IncFaultID
Dim objRS 'Declare variable to create the recordset object
set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;) 'Create the recordset object
objRS.Open &quot;Faults&quot;, strConnect, adOpenKeySet, adLockOptimistic 'Connect to the database and open the staff table
objRS.MoveLast


IncFaultID = objRS.Fields(&quot;FaultID&quot;) + 1 'Incrementing the faultID by one each time a fault is being added to the database.

objRS.AddNew ' Add new recordset to the database
objRS.Fields(&quot;FaultID&quot;) = IncFaultID ' Write details to the database
objRS.Fields(&quot;DateLogged&quot;) = Date
objRS.Fields(&quot;TimeLogged&quot;) = Time
objRS.Fields(&quot;StaffNo&quot;) = Session(&quot;StaffNo&quot;)
objRS.Fields(&quot;TypeOfFault&quot;) = Request.Form(&quot;FaultType&quot;)
objRS.Fields(&quot;RoomNo&quot;) = Request.Form(&quot;Location&quot;)
objRS.fields(&quot;FaultDescription&quot;) = Request.Form(&quot;Details&quot;)
objRS.Fields(&quot;Status&quot;) = &quot;UnAssigned&quot;
objRS.Update

objRS.Close
Set objRS = Nothing

Dim cdoConfig
Dim cdoMessage
Dim theSchema

theSchema = &quot; Set cdoConfig = Server.CreateObject(&quot;CDO.Configuration&quot;)
cdoConfig.Fields.Item(theSchema & &quot;sendusing&quot;) = 2
cdoConfig.Fields.Item(theSchema & &quot;smtpserver&quot;) = &quot;mail.btopenworld.com&quot;
cdoConfig.Fields.Update

Set cdoMessage = Server.CreateObject(&quot;CDO.Message&quot;)
cdoMessage.Configuration = cdoConfig
cdoMessage.From = Session(&quot;EmailAddress&quot;)
cdoMessage.To = &quot;Sunil_mepani@hotmail.com&quot;
cdoMessage.Subject = Request.Form(&quot;FaultType&quot;)
cdoMessage.TextBody = Request.Form(&quot;Details&quot;)
cdoMessage.Send

Set cdoMessage = Nothing
Set cdoConfig = Nothing


Response.Redirect &quot;FaultConfirmation.asp&quot;

If anyone knows what I am doing wrong could they please tell me.
Thanks in advance
 
What platform are you using? Win 2000? Win XP? The methods of CDO are different for different versions on Windows (odd, I know, but true).

An alternative is to use a 3rd party product. We use W3Jmail and it works great for our needs. And it has a free download. It may be worth a look:

 
I have previously used CDONTS to send my mail,

set cdoMessage = server.createobject(&quot;CDONTS.NewMail&quot;)
cdoMessage.To = &quot;Sunil_mepani@hotmail.com&quot;
cdoMessage.From = Session(&quot;EmailAddress&quot;)
cdoMessage.Subject = Request.Form(&quot;FaultType&quot;)
objSendMail.Body = Request.Form(&quot;Details&quot;)

objSendMail.Send

Don't think you have to set anything up on the server for this

Hope it helps

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top