Friday, November 28, 2008

send mail

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry


public void SendMail()
{
//Builed The MSG

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(txtemail.Text);
// msg.To.Add("1980dinesh@gmail.com");
msg.From = new MailAddress("dinesh.kumar@mobilex.in", "Friends Invitaion", System.Text.Encoding.UTF8);
msg.Subject = "Frineds";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = "Hi" ;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;

//Add the Creddentials
SmtpClient client = new SmtpClient();
//client.UseDefaultCredentials = false;
//client.Credentials = new System.Net.NetworkCredential("dinesh.kumar@mobilex.in", "dinesh08");
//client.Port = 587;//or use 587
//client.Host = "smtp.gmail.com";
client.EnableSsl = true;

try
{
client.Send(msg);
//you can also call client.Send(msg)


}
catch (System.Net.Mail.SmtpException ex)
{

}
}
<appSettings/>
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" port="587" userName="suresh.chandra@swaransoft.com" password="xyz"/>
</smtp>
</mailSettings>
</system.net>

No comments: