I asked the following question before I followed theses instructions and got a form to be sent through my email (thank god!) http://aspnet.4guysfromrolla.com/articles/072606-1.aspx __________________________________________________________________ The code that work for me is as follows, and that may work for anyone using asp.net 2.0 as long as they also "Configure SMTP e-mail settings" in their "ASP.Net Web Application Administration Tool" with "visual web developer 2005" <%@ Page Language="VB" %> <%@ Import Namespace="System.Net.Mail" %></o> </o> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></o> </o> <script runat="server"></o> </o> </o> Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click</o> '!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS</o> Const ToAddress As String = "[email protected]"</o> </o> '(1) Create the MailMessage instance</o> Dim mm As New MailMessage(UsersEmail.Text, ToAddress)</o> </o> '(2) Assign the MailMessage's properties</o> mm.Subject = Subject.Text</o> mm.Body = Body.Text</o> mm.IsBodyHtml = False</o> </o> '(3) Create the SmtpClient object</o> Dim smtp As New SmtpClient</o> </o> '(4) Send the MailMessage (will use the Web.config settings)</o> smtp.Send(mm)</o> End Sub</o> </o> </o> </script></o> </o> <html xmlns="http://www.w3.org/1999/xhtml" ></o> <head runat="server"></o> <title>Untitled Page</title></o> </head></o> </o> <form id="form1" runat="server"></o> <div></o> </o> <table border="0"></o> <tr></o> <td>Your Email:</b></td></o> <td><asp:TextBox runat="server" ID="UsersEmail" Columns="30"></asp:TextBox></td></o> </tr></o> <tr></o> <td>Subject:</b></td></o> <td><asp:TextBox runat="server" ID="Subject" Columns="30"></asp:TextBox></td></o> </tr></o> <tr></o> <td colspan="2"></o> Body:</b></o> <asp:TextBox runat="server" ID="Body" TextMode="MultiLine" Columns="55" Rows="10"></asp:TextBox></o> </td></o> </tr></o> <tr></o> <td colspan="2" align="center"></o> <asp:Button runat="server" ID="SendEmail" Text="Send Feedback" /></o> </td></o> </tr></o> </table> </o> </o> </o> </div></o> </form></o> </body></o> </html> ______________________________________________________________ My original question: </o> I am trying to make a form that?s sends the information to my email address, and I?m having problems, and I feel stupid? (I hear its easy but I?m not having any luck?) I have checked out heaps of walkthroughs on the matter, and I am using this one, and I like this one the best: http://www.sitepoint.com/article/sending-web-email-asp-net I have tried to use the example scrip on the above link and came up with heaps errors, so I tried to make the simplest form I could, here is what I came up with: <%@ Page Language="VB" %> <%@ Import Namespace="System.Web.Mail" %></o> </o> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></o> </o> <script runat="server"></o> </o> Dim objMail As New MailMessage()</o> objMail.From = "[email protected]"</o> objMail.To = "[email protected]"</o> objMail.BodyFormat = MailFormat.Html</o> objMail.Subject = "My first ASP.NET email"</o> objMail.Body = "This is my first email sent via ASP.NET. "</o> </o> SmtpMail.Send(objMail)</o> </o> </script></o> </o> <html xmlns="http://www.w3.org/1999/xhtml" ></o> <head runat="server"></o> <title>Untitled Page</title></o> </head></o> </o> <form id="form1" runat="server"></o> <div></o> </o> I HAVE NOT TRIED TO ADD TOO MUCH HERE, AS THE TOP SECTION IS COMING UP WITH ERRORS AND I AM SURE IS MISSING BITS I WOULD LOVE SOME GOOD CODE FOR THIS WHOLE THING If you were wandering what msresume means, I am making a site for My Supper Resume in my country</o> <td class="main"><input type="Submit" </o> id="btnSubmit" OnServerClick="btn_Click" value="Send" </o> runat="server" /></td> </o> </div></o> </form></o> </body></o> </html> This is the SMTP connection in my web.config: I would have used my discountasp.net smtp server but its not working, and my smtpout.secureserver.net (SMTP) definitely is working <system.net></o> <mailSettings></o> <smtp from="[email protected]"></o> <network host="smtpout.secureserver.net" password="**********" port="80" userName="[email protected]"/></o> </smtp></o> </mailSettings></o> </system.net></o> </o> This is the first error message I come up with, but I got a feeling theresmore to come.. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30188: Declaration expected. Source Error: Code: Line 6: Line 7: Dim objMail As New MailMessage() Line 8: objMail.From = "[email protected]" Line 9: objMail.To = "[email protected]" Line 10: objMail.BodyFormat = MailFormat.Html Source File: C:\Documents and Settings\admin\My Documents\Visual Studio 2005\WebSites\formEmail21\Default2.aspx Line: 8 </o> I WOULD LOVE SOME CODE THAT WILL WORK FOR ME Post Edited (vandiermen) : 12/21/2006 5:30:01 PM GMT
OK to start with maybe there's a problem with using version 1.1 code with a version 2.0 site </o> </o> I just saw on the site I'm getting the code from (http://www.sitepoint.com/article/sending-web-email-asp-net ) that it is code for v1.1, and I usually use 2.0 and maybe it incompatible with my web.config or something????
I have been testing this form on my local computer using visual web developer debugger, I have not uploaded it, so I don?t know how visual web developer determines whether it?s a asp.net 1.1 site or asp.net 2.0
This would be the working web.config for ASP.NET 2.0 smtp: <configuration> <appSettings/> <connectionStrings/> <system.net> <mailSettings> <smtp> <network host="localhost" port="25" /> </smtp> </mailSettings> </system.net> <system.web> <customErrors mode="Off"/> <compilation debug="false"> </compilation> </system.web> </configuration> The inherits for your code page: Imports System.Net.Mail Imports System.Net
I followed theses instructions and got a form to be sent through my email (thank god!) http://aspnet.4guysfromrolla.com/articles/072606-1.aspx Budget Web Design Australia www.budgetwebdesign.com.au