Read this article from code project.
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add("reciver@gmail.com"); msg.To.Add("another.reciver@yahoo.com"); msg.From = new MailAddress("dummy@gmail.com", "One Ghost",System.Text.Encoding.UTF8); msg.Subject = "Test mail using .net2.0"; msg.SubjectEncoding = System.Text.Encoding.UTF8; msg.Body = "This is my msg Body"; msg.BodyEncoding = System.Text.Encoding.UTF8; msg.IsBodyHtml = false; msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential("dummy@gmail.com", "SecretPass"); client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted); object userState=msg; try { client.SendAsync(msg, userState); } catch (System.Net.Mail.SmtpException ex) { MessageBox.Show(ex.Message, "Send Mail Error"); }
|
No comments:
Post a Comment