C# email form doesn't send email, but no compilation errors

I'm trying to get an email form to work.  It is a feedback form.  I wrote it in C#.

The existing code returns no compilation errors and appears to work, but the email never gets delivered.  Is there something simple I'm forgetting about? 

The email is a godaddy account.  I'm not sure if that has anything to do with it, but godaddy didn't help me at all so now I'm at a loss on what to do next.


<%@ Page Language="C#" Explicit="true" MasterPageFile="~/MasterPage.master" %>
<%@ Import NameSpace="System.Web.Mail" %>

<asp:Content ID="Title" ContentPlaceHolderID="Title" runat="server">
AS2 | Contact Form

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">

<script runat="server">
    protected void Page_Load(Object Sender, EventArgs e) {
            Message.Text = "";

    protected void Send_Email(Object Sender, EventArgs e) {
        MailMessage mail = new MailMessage();

            mail.To = "webmaster@angiesims2.com";
            mail.From = Request.Form["from"];
            mail.BodyFormat = MailFormat.Html;

            mail.Subject = "AS2 message - " + Request.Form["subject"];
            mail.Body = "Message from " + Request.Form["name"] + ":<br />" + Request.Form["body"];


        Message.Text = "<h2>Email Sent!</h2><h3><a href='email.aspx'>OK</h3>";


<asp:label id="Message" runat="server" />

<% if(!Page.IsPostBack) { %>

<table border="0" align="left" cellpadding="2" cellspacing="2">
        <td>Your Name: </td>
        <td><input type="text" name="name" size="50" maxlength="50"/></td>
        <td>Your Full Email Address: </td>
        <td><input type="text" name="from" size="50" maxlength="50"/></td>
        <td><input type="text" name="subject" size="50" maxlength="50"/></td>
        <td valign="top">Body: </td>
        <td><textarea name="body" cols="40" rows="4"></textarea></td>
        <td colspan="2" align="center">&nbsp;
        <td colspan="2">
        <input type="submit" OnServerClick="Send_Email" runat="server"
        value="Send Email" />

<% } %>


4/20/2008 2:24:04 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 29

Take a look at SmtpMail.SmtpServer

Here is some information according to the documentation: 

The name of the e-mail relay server. If System.Web.Mail.SmtpMail.SmtpServer is not set, the name of the local SMTP server is used.

What this is saying...  if you do not specify a name, the local server is used.  I'm shooting in the dark a tad bit here, but I'm assuming if your local server is not configured, it will not send.


 As per the documentation, I would recommend using the recommended alternative: System.Net.Mail.

4/20/2008 6:46:15 PM

 Thanks for the help.  I've been searching info about System.Net.Mail, but I'm still unsure of how to use it for my code.  Anyone have any ideas?

4/21/2008 1:31:23 AM

I get the following error when trying to use the code from this website: http://www.systemnetmail.com/faq/2.4.aspx   

CS0246: The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)

SmtpClient smtp = new SmtpClient("smtpout.secureserver.net");

4/21/2008 2:01:17 AM

Be sure you import the System.Net.Mail namespace at the top of your page. Basically, the compiler can't find the namespace that contains the SmtpClient class.

Some of my websites
4/22/2008 10:53:16 PM

Thanks!  I made the change: <%@ Import NameSpace="System.Net.Mail" %>

But now I'm getting the error: CS0200: Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assigned to -- it is read only


4/25/2008 9:49:32 PM

 Post your new code.

4/29/2008 12:50:28 AM

Similar Artilces:

There was an error sending mail from 'bugzilla maintainer email' to 'bugzilla user email': Couldn't connect to email.company.com
hi, when users submit new tickets, they receive the this error: There was an error sending mail from 'bugzilla maintainer email' to 'bugzilla user email': Couldn't connect to email.company.com Traceback: at Bugzilla/Mailer.pm line 190 Bugzilla::Mailer::MessageToMTA(...) called at Bugzilla/BugMail.pm line 370 Bugzilla::BugMail::sendMail(...) called at Bugzilla/BugMail.pm line 272 Bugzilla::BugMail::Send(...) called at /srv/www/htdocs/bugzilla/post_bug.cgi line 226 We are running bugzilla version 4.2.1 on Linux using smtp settings with authenticated user ...

send web email from web form error help
Hi, When send email with attachment from web form. I got an error message as below. What it is? Can someone help? Server Error in '/dotNet' Application. -------------------------------------------------------------------------------- The transport lost its connection to the server. Hi There, Please check the following link The transport failed to connect to the server Hope this helps Sunny NAGIProper Preparation Prevents Poor PerformanceDont forget to click "Mark as Answer" on the post that helped you....

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/da...

Sending email through web form (C#)
Hi, I want to provide a link on my web form which when clicked by a customer will open up his local email program so that he can send regular email to anyone. Please provide code in C# if possible. Regards, Sandyhttp://www.thequinn.infohttp://www.sksdataservices.comhttp://www.infobasket.info all u need is to provide a hyperlink with the email address of the receiver. <a href="mailto:help@microsoft.com">Send Email</a>Sending Email Through Code Example HCHaissam Abdul MalakMCAD.NET| Blog |...

WindowsApplication can send email,but WebApplication can't send,and don't show error.
WindowsApplication can send email,but WebApplication can't send,and don't show error. this is code Dim strBody As String = "This is the body..." Dim OLApp As New outlook.Application() Dim msg As outlook.MailItem msg = OLApp.CreateItem(outlook.OlItemType.olMailItem) msg.To = "sbzhong@cclmotors.com" msg.Subject = "Automated e-mail" msg.Body = strBody CType(msg, outlook._MailItem).Send() ...

Send email error from my web form question
I keep getting this fatal error when I try to send email from my web form internally.  For some reason, when I set the (to) address to a valid email address that is external it works, but when I try sending a valid email internally it will not work.  I even broke the mail function down to the bare minimum to send a sample email.  I even hard coded the addresses right in the (to) and (from) fields.  No matter what I try, it produces the same results.  If I change the (to) email address to anything external, it will work perfectl...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

A problem to send email using Smtp
I have a proble to send an email from asp.net I do the following code to send an email: MailMessage mail=new MailMessage(); mail.From="test@server.com"; mail.To="myemailaddress@server.com"; mail.BodyFormat=MailFormat.Html; mail.Subject="testing..."; mail.Body="cool"; SmtpMail.SmtpServer="localhost"; SmtpMail.Send(mail); But I dont' receive an email when I use this method. Why is that? How can I send an email? Thanks in advance! check and see if.. -your client-side code has no errors -you imported the S...

Email gets a send error but still goes into Sent folder. Sometimes successfully sends and sometimes doesn't
The error message we recieve sometimes on an employee's computer when sendi= ng mail reads "An error occured while sending mail. The mail server respond= ed: Resources temporarily unavailable - Please try again later. Please chec= k the message and try again" Thunderbird then proceeds to put the message in the Sent folder after hitti= ng OK, defeating the purpose of the error in my opinion. Whether or not it successfully sends is completely unknown to us unless the= person replies or the person it was emailed to is within our office; howev= er, when sending the email...

Contact Form won't send an Email
I have a contact form that came with the "Personal" template, which I got from Microsoft here.  It comes with a contact form, but I'm having a helluva time trying to figure out how to make it actually send the email.  Any help would be appreciated.  Here's what my contact form looks like right now: <div id="contactForm">     <fieldset style="width: 300px;">          <legend style="background-color: #F0E6B5">Who you are</legend><asp:L...

sendAsync email with 'sending email' screen and 'email sent' screen
hi i have written my first sendAsync contact form that sends me an email and it works fine. and when the sendCompletedCallback event is fired the contact form is set to display:none and screen is shown that says message sent. i am planning on adding an intermediate 'sending email' screen. is this a good idea is it necacery? can this only be done by calling a javascript function from the form's button's onclick event handler? or can it be done in the code behind by sending a response to the submitted form straight away before it is processed and then sending another when the e...

Email-subscription doesn't work under forms security
Hi, Email-subscription works under windows security, but it doesn't work under forms security. The error is "Object reference not set to an instance of an object." Any ideas?...

FATAL ERROR: DotNetNuke.com doesn't send emails
No new users can sign up and download the code. When I registered at dotnetnuke.com the request timed out. Then it gave the message that I need to enter the validation code. Ofcourse no mail arrived. I've now tried four times, sometimes it times out, sometimes not (but it takes like 60 sec). I still never get a mail. I've mailed the author, perhaps he reads here too... Everything I ever needed to know I learned by killing smart people and eating their brains. http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=682179ChrisHammond.comEngage Software...

Email Comment Form Doesn't Enter Access Database
I want to send out email newsletters with a form so that people can respond easily to me here is the form <form name="comment" method="GET" action="http://www.giboneydesigns.com/giboneydesigns/webot/email2.aspx" target="_self"> <p>Send us a Comment!<br><br> Name: <br><input name="name" width="100"> <br><br> Comment: <textarea name="comment" rows="5"></textarea> <br> <input type="submit" value=&...

Web resources about - C# email form doesn't send email, but no compilation errors - asp.net.web-forms

Resources last updated: 1/18/2016 12:36:21 AM