View Full Version : Problems sending an EMAIL using CDO.MESSAGE
sameermaira
12-15-2005, 12:04 PM
Hi ,
I have a simple form with 3 fields. "Nick" , "Name" & Country. When the user presses the Submit button I update a database. Besides updating the database I would also like to send an EMAIL with the information of the new user to myself.
The following is the ASP file that I use followed by the error that I get when I press SUBMIT. Please note that the database is getting updated. The problem lies in the code to send an email.
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->
<!--#include file="DatabaseConnect.asp"-->
<%
Dim objRS,email
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open "info", objConn, 3, 3
While Not objRS.EOF
If Request.Form("Nick")=objRS("Nick") then
Response.Redirect "exists.html"
end if
objRS.MoveNext
Wend
objRS.AddNew
objRS("Nick")=Request.Form("Nick")
objRS("Name")=Request.Form("Name")
objRS("Country")=Request.Form("Country")
objRS.Update
Set email = Server.CreateObject("CDO.Message")
email.from = "Yahoo Idol"
email.to = "yahooidol@rediffmail.com"
email.subject = "New Registration"
email.htmlbody = "These are the details of the registered user <br>" & Request.Form("Nick") & "<br>" & Request.Form("Name") & "<br>" & Request.Form("Country")
email.send
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
Response.Redirect "thanks.html"
%>
This is the error I get.
Error Type:
CDO.Message.1 (0x80040220)
The "SendUsing" configuration value is invalid.
/yahoo idol/register.asp, line 28
BarrMan
12-15-2005, 12:20 PM
First, from where have you tried sending this email? if from localhost then i think it isn't installed in your computer.
Second,
objRS.Open "SELECT * FROM info WHERE nick='" & request.form("nick") & "'",objConn, 3, 3
If objrs.eof then
'Do the new raw code
Else
response.redirect "exists.html"
End If
sameermaira
12-15-2005, 12:26 PM
Yes i was trying to send it via localhost. Should I upload the script on the server and try sending it from there ?
BarrMan
12-15-2005, 12:29 PM
yes, the email send looks fine, it should work... but the query i mentioned above won't work.
sameermaira
12-15-2005, 12:39 PM
Okay , I uploaded the ASP file to the server and tried it from there. I still get an error .
Here's the error
CDO.Message.1 error '80070005'
Access is denied.
/yahooidol/register.asp, line 28
Here is my Site's address -> http://k.domaindlx.com/yahooidol/
here's the ASP FILE.
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->
<!--#include file="DatabaseConnect.asp"-->
<%
Dim objRS,email
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open "info", objConn, 3, 3
While Not objRS.EOF
If Request.Form("Nick")=objRS("Nick") then
Response.Redirect "exists.html"
end if
objRS.MoveNex
Wend
objRS.AddNew
objRS("Nick")=Request.Form("Nick")
objRS("Name")=Request.Form("Name")
objRS("Country")=Request.Form("Country")
objRS.Update
Set email = Server.CreateObject("CDO.Message")
email.from = "Yahoo Idol"
email.to = "yahooidol@rediffmail.com"
email.subject = "New Registration"
email.htmlbody = "These are the details of the registered user <br>" & Request.Form("Nick") & "<br>" & Request.Form("Name") & "<br>" & Request.Form("Country")
email.send
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
Response.Redirect "thanks.html"
%>
BarrMan
12-15-2005, 12:46 PM
I get page cannot be desplayed... change this:
objRS.Open "info", objConn, 3, 3
While Not objRS.EOF
If Request.Form("Nick")=objRS("Nick") then
Response.Redirect "exists.html"
end if
objRS.MoveNex
Wend
To this:
objRs.Open "SELECT * FROM info WHERE nick='" & request.form("nick") & "'", objConn, 3, 3
If objRs.EOF then
'Do the new raw
Else
Response.redirect "exists.html"
End If
sameermaira
12-15-2005, 01:01 PM
Hi barrman ,
Im sorry I cannot understand what you are telling me to do .
What does this mean 'Do the new raw ?
If I replace my code with the one you sent me then the whole functionality of the script will change.
Could you please let me know in more detail what has to be done.
Thank's for your patience.
BarrMan
12-15-2005, 01:18 PM
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->
<!--#include file="DatabaseConnect.asp"-->
<%
Dim objRS,email
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT * FROM info WHERE nick='" & Request.Form("nick") & "'", objConn, 3, 3
If objRS.EOF Then
objRS.AddNew
objRS("Nick")=Request.Form("Nick")
objRS("Name")=Request.Form("Name")
objRS("Country")=Request.Form("Country")
objRS.Update
Set email = Server.CreateObject("CDO.Message")
email.from = "Yahoo Idol"
email.to = "yahooidol@rediffmail.com"
email.subject = "New Registration"
email.htmlbody = "These are the details of the registered user <br>" & Request.Form("Nick") & "<br>" & Request.Form("Name") & "<br>" & Request.Form("Country")
email.send
Else
response.redirect "exists.html"
End If
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
Response.Redirect "thanks.html"
%>
sameermaira
12-15-2005, 01:37 PM
Hi again ,
I uploded the file you sent me but I still get an error message.
CDO.Message.1 error '80070005'
Access is denied.
/yahooidol/register.asp, line 23
The Database is getting updated and everything else is working fine too. But the email is not going.
BarrMan
12-15-2005, 02:50 PM
This code is register.asp? if so, is the line that causes the problem is else? if not please post the right code and mention what line causes the problem.
sameermaira
12-15-2005, 04:14 PM
CDO.Message.1 error '80070005'
Access is denied.
/yahooidol/register.asp, line 20
Yes it is the file "Register.asp" .
Here is the code.
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->
<!--#include file="DatabaseConnect.asp"-->
<%
Dim objRS,email
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT * FROM info WHERE nick='" & Request.Form("nick") & "'", objConn, 3, 3
If objRS.EOF Then
objRS.AddNew
objRS("Nick")=Request.Form("Nick")
objRS("Name")=Request.Form("Name")
objRS("Country")=Request.Form("Country")
objRS.Update
Set email = Server.CreateObject("CDO.Message")
email.from = "Yahoo Idol"
email.to = "yahooidol@rediffmail.com"
email.subject = "New Registration"
email.htmlbody = "These are the details of the registered user <br>" & Request.Form("Nick") & "<br>" & Request.Form("Name") & "<br>" & Request.Form("Country")
email.send
Else
response.redirect "exists.html"
End If
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
Response.Redirect "thanks.html"
%>
I removed all the spaces between lines to see what line the error occurs at. Line 20 , is "email.send"
Thanks
BarrMan
12-15-2005, 04:24 PM
I think it's a problem with your server... try uploading it on another server.
BarrMan
12-15-2005, 06:05 PM
yup, the problem was the server... the server does not support smtp and email functions... if anyone knows of some good other free hosting site that support email sending in asp that would be nice if you post it here.
Thanks.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.