Click here to Skip to main content
15,924,317 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
I have copy feedback form from this side it is running but mail is not going and it is giving"Send Email FailedThe specified string is not in the form required for an e-mail address".please give the solution of it...
C#
using System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
    protected void btnSendmail_Click(object sender, EventArgs e)
    {
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();
        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
            smtpClient.Host = "localhost";
            smtpClient.Port = 25;
            message.From = fromAddress;
            message.To.Add("teddy.shally@gmail.com");
            message.Subject = "Feedback";
            message.CC.Add("teddy.shally@gmail.com");
            message.CC.Add("agarwal.neha.0703@gmail.com.com");
            message.Bcc.Add(new MailAddress("tushargupta251@gmail.com."));
            message.Bcc.Add(new MailAddress("admin4@yoursite.com"));
            message.IsBodyHtml = false;
            message.Body = txtMessage.Text;
            smtpClient.Send(message);
            lblStatus.Text = "Email successfully sent.";
        }
        catch (Exception ex)
        {
            lblStatus.Text = "Send Email Failed" + ex.Message;
        }
    }
    
    protected void btnReset_Click(object sender, EventArgs e)
    {
      txtName.Text = "";
      txtMessage.Text = "";
      txtEmail.Text = "";
    }
}
Posted
Updated 20-Jun-11 7:03am
v2

The format for one of your email ids is wrong. There are two coms in it.
 
Share this answer
 
Comments
fjdiewornncalwe 20-Jun-11 15:10pm    
Correct. The error messages usually point to the issue. The hint in the error is "email address". +5
Abhinav S 21-Jun-11 0:23am    
Thank you Marcus.
for sending mail through your appication check this link it will definetly help you...

http://myashkap.wordpress.com/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900