Click here to Skip to main content
15,923,087 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected void btnSubmit_Click(object sender, EventArgs e)
    {

        MailMessage Msg = new MailMessage();
        Msg.From = new MailAddress("lathag3093@gmail.com");
        Msg.To.Add(txtToMail.Text);
        //Msg.Subject = txtSubject.Text;
        Msg.Body = txtSubject.Text;
        Msg.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gamil.com";
        System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
        NetworkCred.UserName = "lathag3093gmail.com";
        NetworkCred.Password = "";
        smtp.UseDefaultCredentials = true;
       
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.Send(Msg);
        lblMsg.Text = "Email has been successfully sent..!!";



    }


What I have tried:

..This error I got..Can anyone suggest me to solve the problem
Posted
Updated 9-Apr-20 11:51am
v2
Comments
Member 14797468 9-Apr-20 17:24pm    
Plz give back my gmail id .it receive email.but it dose not sent email.plz help me

You mis-spelled gmail in below line, fix that and try again:
smtp.Host = "smtp.gamil.com";
 
Share this answer
 
Comments
Maciej Los 11-May-17 2:30am    
Hawk eye!
5!
try this :

smtp.Host = "smtp.gmail.com";
 smtp.Timeout = 10000;
 
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