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

Email data from Form

Status
Not open for further replies.

katherinep

Programmer
Sep 18, 2003
49
AU
Hello,

I know there are many posts on the subject but I can't find anything that doesnt confuse me! This is so easy to do in ColdFusion I can't believe it can be so tricky in ASP!

All I want to do is after the user has filled in a form to email the form data to me. I have been playing about with different bits of code all afternoon but I am not getting anywhere! Can anyone either post some code or point me in the correct direction?

Thanks so much, its driving me crazy!

Katherine
 
Post some of the bits of code that you have been playing with.

- FateFirst
 
What have you been working with?

Windows NT and Windows 2000 came with CDONTS on it. It's afairly simple object to use but that is becaue it has very little functionality. It is also being phased out (or rather, it was included in 2000 to start phasing it out and people keep using it).

Windows 2000, XP, 2003 came with a differant (read, newer) object called CDOSYS or CDO. This object is a littlemore complex because there are a lot more things you can mess with, but that also means it has greater functionality.

Maybe if you post your two attempts and the errors you were getting we could assist you in making them work, make be eaier then starting all over from scratch and would help you the next time you ran into a problem with this stuff :)

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
Thanks for your help guys!

Here is my form:

--------------------------------------------------
<form action="thankyou.asp" method="post" name="feedback_form" id="feedback_form">
<p>

<p class="headingtext">Where Your Opinion Counts </p>
<p class="bodytext">Please complete the form below with any ideas and feedback</p>
<table width="440" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td align="right" class="headingtext">Name</td>
<td width="10" rowspan="3" align="left" valign="top">&nbsp;</td>
<td width="75">
<input type="text" name="Name" size="20" maxlength="80" />
</td>
<td width="*" rowspan="3" class="tiny">&nbsp;</td>
</tr>
<tr>
<td align="right" class="headingtext">E-mail address</td>
<td><input type="text" name="Email" size="20" maxlength="80" />
</td>
</tr>
<tr>
<td align="right" valign="top"><div align="left"><span class="headingtext">Your Ideas</span> - <span class="bodytext"><br/>
We want to hear your ideas for the types of events and activities you would like to see take place:</span></div></td>
<td>
<textarea name="Ideas" cols="40" rows="4"></textarea>
</td>
</tr>
<tr>
<td align="right" valign="top"><div align="left"><span class="headingtext">Your Feedback</span> - <span class="bodytext"><br/>
We would like to hear your feedback (good and bad)</span></span>: </div></td>
<td align="left" valign="top">&nbsp;</td>
<td><textarea name="Feedback" cols="40" rows="4"></textarea></td>
<td>&nbsp;</td>
</tr>
</table>
<br/>
<center>
<input type="submit" value="Send" />
<input type="reset" value="Clear" />
</center><br/>
</form>

--------------------------------------------------
And here a bit of code, have been playing to CDO and CDONTS. I am running XP but I don't know what my users will have!

This code give me this error:

ActiveX component can't create object: 'CDO.Message'


--------------------------------------------------
dim formElements
formElements = ""
formElements = formElements & "Name: " & Request("Name") & "" & vbcrlf
formElements = formElements & "Description: " & Request("Email") & "" & vbcrlf
formElements = formElements & "Web Address: " & Request("Ideas") & "" & vbcrlf
formElements = formElements & "Return Link: " & Request("Feedback") & ""



Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Feedback "
objMessage.From = "my@email.com"
objMessage.To = "my@email.com"
objMessage.TextBody = "This is a my form element:" & formElements
objMessage.Send

---------------------------------------------
I also tried this but wasn't sure what to put in for mailserver:
----------------------------------------------------
sch = " Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "<enter_mail.server_here>"
cdoConfig.fields.update

Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = "from@me.com"
cdoMessage.To = "to@me.com"
cdoMessage.Subject = "Sample CDONTS NewMail"
cdoMessage.TextBody = "This is a test for CDONTS message"
cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing
--------------------------------------------------

I also tried example from



And finally this,
--------------------------------------------------
<%
Dim MyBody
Dim MyCDONTSMail
%>

<%
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From= "my@email.com"
MyCDONTSMail.To= "my@@email.com"
MyCDONTSMail.Subject="This is a Test"
MyBody = "results from page" & vbCrLf
MyBody = MyBody & "We appreciate your business" & vbCrLf
MyBody = MyBody & "Your stuff will arrive within 7 business days"
MyCDONTSMail.Body= MyBody
MyCDONTSMail.Send
set MyCDONTSMail=nothing
%>
--------------------------------------------------
Any ideas or am I totally on the wrong track? I tried the last few just to get an email through but I got nothing.

Katherine
 
Ok, the last one won't work because CDONTS isn't included in windows XP.

The first two both use the CDO object, which should be on your system already. The difference between the first and second ones are that in the second one your telling it which mail server to send out on. This should generally be the email server for the same domain as the sender. I believe otherwise it will use the default setting in IIS (if it is set) or it will attempt to send using your computer as the originating SMTP server (which many mail servers now block in an attempt to control spam).

The second one should work, provided you give it an SMTP server address to send through. For example, when you set up something like MS Outlook to check your email and to send email back, you have to enter an SMTP server address for outgoing mail. In this situation you would want to use the same address for your settings because you wantto send some outgoing mail through that email server. If you don't have something like outlook set up we may be able to help if it is a rented web host. If it is a corporate network we can probably provide suggestions (read as: guesses).

-T


01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
So if I use the the first one, where I don't need to put in the mail server, do you know why I am getting that error message? Is it something i need to set on my computer?

Thanks,

Katherine
 
Sorry forgot

also if we are using outlook what would the mail server be is that like SMTP?

Ktaheirne
 
Hello again,

Still working on this. I saw some articles saying the error

'ActiveX component can't create object: 'CDO.Message' '

may be due to not having the right dll, namely CDO.DLL. I downloaded this and it still comes up with the same error. Anyone have any ideas?

Katherine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top