Click to See Complete Forum and Search --> : Urgent CDO issue


minority
09-15-2005, 06:51 AM
hi i has just moved my site onto server 2003 from xp...

got thorugh issues with moving from 5.0 to 6.0 with little problem

but i used cdo to send email out to new users and now it doesnt like it....

I have edited my code to use my companys smtp server and port etc....but it keeps coming up with the following error
ADODB.Fields error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/qms/Admin/site/newusersql.asp, line 47


the code looks like this can anyone help me i really need to get this working by the end of tomorrow.


<!--#include file="../testsecurity2.asp"-->
<!--METADATA
TYPE="TypeLib"
NAME="Microsoft ActiveX Data Objects 2.7 Library"
UUID="{EF53050B-882E-4776-B643-EDA472E8E3F2}"
VERSION="2.7"
-->


<% levelcheck(3)%>
<% Username = Request.Form("Username")
Securelevel = Request.Form("Securelevel")
Fullname = Request.Form("name")
Email = Request.Form("Email")


'If the username and email are not in the database
'If they are not found then the information is added to the database and redirected to the admin index page.

Set rsGeolink = Server.CreateObject("ADODB.Recordset")
set rsinsert = server.CreateObject ("ADODB.Connection")
rsinsert.open = strCon
strSQLcheck = "SELECT User, Email From users where User='"& Username & "' OR Email = '"&Email&"'" 'Check to see if the username and email are already in the database
rsGeolink.Open strSQLcheck, rsinsert ' Start the checking of the username and email
If rsGeolink.eof then
strSQL = "INSERT INTO users ([User], [FullName], [Email], [SecurityLevel]) VALUES ( '" & Username & "' , '" & Fullname & "' , '" & Email & "' , '" & Securelevel & "')"

rsinsert.execute (strSQL)
rsinsert.Close
Set rsinsert = Nothing
if Securelevel = 1 then
access = "Standard User"
else if Securelevel = 2 then
access = "Basic Administrator"
else
access = "Site Administrator"
end if
end if
'Bellow will create an email and send it out to the new user of the system to inform them that they are now a user of the system and the web address.




Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(cdoSendUsingMethod) = 25
.Item(cdoSMTPServer) = "Ip taken out eg 10.1.1.1"
.Update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = trim(session("Email"))
.To = Email
.Subject = "New QMS User"
.TextBody = "<img src=""Http://geolink1/qms/Images/icons/Geolink.gif""><p> <Strong>Welcome "&Fullname&",</Strong><br><br>To the Geolinks Quality Managment System. Please use this system to find the latest documents available to all departments.</p><p>The System can be found at <a href=&quot;http://geolink1/qms/index.asp&quot;>http://geolink1/qms/index.asp</a></p><p>There is no required login process to access the system as the system will automatically detect your Windows Xp Username.</p> <p>Please ensure that the information bellow is correct.</p><p><table><tr> <td><strong>Username:</strong></td><td>"&Username&" </td> </tr> <tr> <td> <strong>Full Name:</strong></td><td>"&Fullname&"</td></tr><tr> <td><strong>Email Address:</strong></td><td>"&Email&"</td></tr><tr> <td><strong>Access Level:</strong></td><td>"&access&"</td></tr></table></p><p>Regards</p><p>"&session("FullName")&" - Site Administrator</p><p>"&session("Email")&"</p>"
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
Response.Redirect("../index.asp")
end if

'If the username or email are found the following checks are made to determine which one is creating the problem.
'Bellow statements check to see whether username &email are in use or just the username or the email are in use.
'A message is then attached to the variable userissue and passed back to newuser with all of the information that was typed in the previous page.
If rsGeolink("user")= UserName AND rsGeolink("Email") = Email then
userissue = ("<strong>Username</strong> and <strong>email</strong> are already in use.<br>To obtain already entered usernames visit the<a href= ""edituser.asp"" class= ""dblist""> Edit User Section</a>")
response.redirect("newuser.asp?userissue=" & userissue & "&user_name="&Username&"&fullname="&Fullname&"&user_email="&Email&"&secure="&Securelevel&"")

Elseif rsGeolink("user")= UserName then
userissue = ("Username is already in the database")
response.redirect("newuser.asp?userissue=" & userissue & "&user_name="&Username&"&fullname="&Fullname&"&user_email="&Email&"&secure="&Securelevel&"")

Else
userissue = ("The email address is already in use")
response.redirect("newuser.asp?userissue=" & userissue & "&user_name="&Username&"&fullname="&Fullname&"&user_email="&Email&"&secure="&Securelevel&"")
End if
response.redirect("newuser.asp?")

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>

slyfox
09-15-2005, 06:44 PM
try this:
dim htmail,sendMail
htmail = '<html>.....your html email....</html>'

Set sendMail = Server.CreateObject("CDONTS.NewMail")
sendMail.To = "some@email.co"
sendMail.From = "Mr. Minority<minor@domain.com>"
sendMail.Value("Reply-To") = "Mr. Minority<wazzup@nowhere.co>"
sendMail.Subject = "To my wife"
sendMail.Body = htmail
sendMail.Importance = 2 ' think 0 = low priority, 1 = normal, 2 = high
sendMail.BodyFormat = 0 ' keep this if sending html emails
sendMail.MailFormat = 0 ' keep this if sending html emails
sendMail.Send() ' if this send does not work, remove it's braces ()
Set sendMail = Nothing

Hope it helps, rather I hope it works, I translated it from ASP JScript (which I use) for you to ASP VB Script co'z I see that's what you're using... anycase, I'll include the original from JScript too...

var htmail = '<html>.....your html email....</html>';

var sendMail = Server.CreateObject("CDONTS.NewMail");
sendMail.To = "some@email.co";
sendMail.From = "Mr. Minority<minor@domain.com>"; // you can do the same with "To"
sendMail.Value("Reply-To") = "Mr. Minority<wazzup@nowhere.co>";
sendMail.Subject = "To my wife";
sendMail.Body = htmail;
sendMail.Importance = 2; // think 0 = low priority, 1 = normal, 2 = high
sendMail.BodyFormat = 0; // keep this if sending html emails
sendMail.MailFormat = 0; // keep this if sending html emails
sendMail.Send(); // This send works
sendMail.Delete;

Bullschmidt
09-20-2005, 03:02 PM
As CDO is generally used instead of CDONTS on IIS 5 and after, here's a nice CDO link even if you don't use the attachment part:
Email (with Attachment)
http://www.asp101.com/samples/email_attach.asp