p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   sending email from a form (http://p2p.wrox.com/showthread.php?t=38426)

x_ray February 13th, 2006 05:18 PM

sending email from a form
 
hello all,

i have started programming using asp.net, and have built a form with multiple input types on it, now i want to submit this form and once submitted, i want it to be send as mail, could anyone give a little example about it? i have searched a little about this topic and found that i have to use CDONTS,(it seems a component responsible for doing all the email stuff) but also i found warnings that to use CDOSYS, both of them i dont know nothing about,so could anyone help me?
thanks,
Best regards


planoie February 13th, 2006 10:46 PM

Look in the System.Web.Mail namespace. .NET has built in classes that should do all of what you need.

http://www.google.com/search?q=System.Web.Mail

-Peter

x_ray February 20th, 2006 05:11 PM

thanks peter, i will check it and get back to you.


x_ray February 21st, 2006 04:47 PM

Peter,

i know this might seems strange, but i am developping the asp.net webapp on my local machine, how should i know if the email was send successfully(no internet connection)?
if you didn't get me let me know, i will try to explain it better since i am new to this kind of stuff.
thanks for your understanding.


x_ray February 22nd, 2006 01:37 PM

ok, i have connected my pc to internet, i have windows xp, and i am using the following code to send the email from the form(it s simple, but doesn't work)(note that this is a portion, without the decalrations for space, if you need the whole code tell me)
Code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
 <% Option Explicit %>
 <%
'Get data from previous page
 sTo = Request("sTo")
 sFrom = Request("sFrom")
 sSubject = Request("sSubject")
 sTextBody = Request("sTextBody")
 sHTMLBody = Request("sHTMLBody")
 
'Only run this if it's not the first time
 If Request.Form("Submit") <> "" Then
 
 Dim objMail
 'Create the mail object
 Set objMail = Server.CreateObject("CDO.Message")
 'Set key properties
 objMail.From = sFrom
 objMail.To = sTo
 objMail.Subject= sSubject
 objMail.TextBody = sTextBody
 objMail.HTMLBody = sHTMLBody
 
'Send the email
 objMail.Send
 'Set sMsg which will be used later
 sMsg = "Your message was sent to: " & sTo
 
 'Clean-up
 Set objMail = Nothing
 
 End If
%>
<html>
 <head><title>SendMail</title></head>
 <body>
  <form action="<%=Request.ServerVariables("PATH_INFO")%>" method="post">
  <table>
    <tr>
      <td>Send To:</td>
      <td><input type="text" name="sTo" value="<%=sTo%>"></td>
    </tr>
    <tr>
      <td>Send From:</td>
      <td><input type="text" name="sFrom" value="<%=sFrom%>"></td>
    </tr>
   <tr>
      <td>Message Subject:</td>
      <td><input type="text" name="sSubject" value="<%=sSubject%>"></td>
    </tr>
    <tr>
      <td>Message Text Body:</td>
      <td><textarea cols="60" rows="5" name="sTextBody">
         <%=sTextBody%></textarea></td>
    </tr>
    <tr>
      <td>Message HTML Body:</td>
      <td><textarea cols="60" rows="5" name="sHTMLBody">
         <%=sHTMLBody%></textarea></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>

  <%=sMsg%>
  </form>
 </body>
 </html>


ok now when i submit, here is the error that i am getting:
CDO.Message.1 (0x80040220)
The "SendUsing" configuration value is invalid.
 what should i do? please i need help, any kind of help or suggestions( i googled a little, but i didn't understand anything of all this technical explanation about windows server... all i am using is windows xp with iis installed!!!)



x_ray February 22nd, 2006 02:58 PM

ok i googled a little and found the solution, thanks on your attention anyway hand :)



All times are GMT -4. The time now is 08:31 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.