Click to See Complete Forum and Search --> : Sending email with CDO problem.


ozpo1
03-09-2006, 11:47 AM
I'm trying to send email, using asp.
However, when I run the following code, I receieve and server internal error, what's wrong with it?

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="karen@mydomain.com"
myMail.To="jean1@yahoo.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>

JayM
03-09-2006, 11:54 AM
What's the error you're receiving? Are you trying to run this on IIS on your local machine? CDO must be installed for this to work on your local machine.

ozpo1
03-09-2006, 05:30 PM
I'm using an external server. This is the error that I receive:

HTTP 500 - Internal server error
Internet Explorer

Also, I asked my host if they have CDO and he told me they do support CDOSYS, which I think is the same.

any idea? what's wrong?

JayM
03-09-2006, 06:37 PM
Yes, that means CDO is supported.


This is a generic error message which Internet Explorer uses to "hide" an actual ASP script error. The HTTP 500 error contains no specific information which would allow you to troubleshoot the problem.

To see a meaningful ASP script error, go to Tools/Internet Options..., open the Advanced tab, and under Browsing, uncheck the option Show friendly HTTP error messages.


Please paste the error after you do the above.

Do you have any other ASP/HTML code on the page?

Regards

ozpo1
03-09-2006, 08:13 PM
A. Thanks for the useful information. I'm very happy to study about that (the a friendly massages thing...).
This is the result that I got:
CDO.Message.1 error '80040220'

The "SendUsing" configuration value is invalid.

/managment/managment.asp, line 7


I do have some html code on this page and that's it. But the page work perfectly fine with out the code for the Email.
Thanks for your time, Oz.

JayM
03-09-2006, 08:34 PM
Hmm. I looked up that error on Google and it seems others have faced this problem, and no solution has been given. Anyway, here's a script I wrote a couple of days ago. I tested this script myself, so it works. Feel free to change it however you wish.

formmail.asp

<html>

<head><title>Contact Page</title></head>

<body>

<%
Dim strIP

strIP = Request.ServerVariables("REMOTE_ADDR")

%>

<p>Welcome to the Contact page. Please feel free to e-mail us with any questions or concerns</p>


<form action="mail.asp" method="Post">

<table>
<tr>
<td>First Name</td>
<td><input type="text" name="firstname"></td>
</tr>

<tr>
<td>Last Name</td>
<td><input type="text" name="lastname"></td>
</tr>

<tr>
<td>E-mail Address</td>
<td><input type="text" name="emailaddress"></td>
</tr>

<tr>
<td>Subject</td>
<td>
<select name="Subject">
<option value="General">General</option>
<option value="Feedback">Feedback</option>
<option value="Quote">Quote</option>
</select>
</td>
</tr>

<tr>
<td></td>
<td><textarea name="body" rows=5></textarea><br /><input type="hidden" value="<% = strIP %>" name="ipaddress" ></td>
</tr>


<tr>
<td>
</td>
<td>
<input type="submit" value="Submit">
</td>
</tr>

</table>

</form>

</body>

</html>





mail.asp

<html>

<head><title>Contact Page</title></head>

<body>

<%

Dim Formmail, strFirstName, strLastName, strEmail, strSubject, strBody, strIP, strTo, strFormat

strFirstName = Request.Form("firstname")
strLastName = Request.Form("lastname")
strEmail = Request.Form("emailaddress")
strSubject = Request.Form("Subject")
strBody = Request.Form("body")
strIP = Request.Form("ipaddress")

strFormat = strFirstName & " " & strLastName & vbCrLf & vbCrLf & vbCrLf & strBody & vbCrLf & fbCrLf & strIP

Select Case strSubject
Case "General"
strTo = "jaym1@hotmail.com"
Case "Feedback"
strTo = "jaym2@hotmail.com"
Case "Quote"
strTo = "jaym3@hotmail.com"
End Select

Set Formmail = CreateObject("CDO.Message")
Formmail.Subject = strSubject
Formmail.From = strEmail
Formmail.TextBody = strFormat
Formmail.To = strTo
Formmail.Send

Set Formmail = Nothing


%>

<body>

<p>Your e-mail has been sent. Thank you.</p>



</body>

</html>


If this script doesn't work then it's a problem with your host.

I did this script really quick, without regard to aesthetics or anything like that. You will have to adjust the looks of it :p . You might also want to add a Server.Transfer("index.asp") or something like that at the end of the page to redirect the user.

Cheers

ozpo1
03-19-2006, 12:17 PM
And for your time. Oz.