I want to send email from windows application using C#, i am developing my project on my laptop, i am connected to internet when i try to send email it fails to send here is the code i have.
my app.congCode:private void button1_Click(object sender, EventArgs e) { try { MailMessage mail = new MailMessage(); mail.To.Add("email1@gmail.com"); mail.To.Add(txtto.Text.ToString()); mail.From = new MailAddress("email2@gmail.com"); mail.Subject = "School Name"; string Body = txtmsg.Text; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new System.Net.NetworkCredential ("simemail@gmail.com", "test12"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; smtp.Send(mail); MessageBox.Show("Mail Send"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
i really want to send email from my windows application using C#, please help meHTML Code:<configuration> <system.net> <mailSettings> <smtp deliveryMethod="network"> <network defaultCredentials="false" host="smtp.gmail.com" port="587" username="simemail@gmail.com" password="test123"/> </smtp> </mailSettings> </system.net> </configuration


Reply With Quote
