Click here to Skip to main content
15,886,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void SendEMail(string emailid, string subject, string body)
{
   SmtpClient client = new SmtpClient();
   client.DeliveryMethod = SmtpDeliveryMethod.Network;
   client.EnableSsl = true;
   client.Host = "smtp.gmail.com";
   client.Port = 587;
   // client.Host = "localhost";
   // client.Port = 25;

   System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("ipower@noreply.com","123qwerty");
   client.UseDefaultCredentials = true;
   client.Credentials = credentials;

   MailMessage msg = new MailMessage();
   msg.From = new MailAddress("noreply@gmail.com");
   msg.To.Add(new MailAddress(emailid));

   msg.Subject = subject;
   msg.IsBodyHtml = true;
   msg.Body = body;

   client.Send(msg);

}



//////////////////////////////////////////////////////////////////////////////////////////////


In my server i have a mail configuration so i can use
C#
client.Host = "localhost";client.Port = 25;

without using any credentials but the main shoud't send please help me

[edit]Code block added, tabulation reduced[/edit]
Posted
Updated 26-Feb-14 22:56pm
v3

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