Sending email .Net [Gmail]

Send email mail1 to mail2

{
            string src_address = "mail1@gmail.com";
            string dest_address = "mail2@gmail.com";

            MailMessage myMail = new MailMessage();
            NetworkCredential Cred = new NetworkCredential(src_address, "password");

            myMail.From = new MailAddress(src_address);          
            myMail.To.Add(dest_address);

            myMail.Subject = "Test send mail message";
            myMail.Body = "Hi !!";

            SmtpClient smtpMail = new SmtpClient();
            smtpMail.Credentials = Cred;
            smtpMail.Host = "smtp.gmail.com";
            smtpMail.Port = 587;
            smtpMail.EnableSsl = true;
            smtpMail.Send(myMail);

            myMail = null;

            return RedirectToAction("Register");
 }

Host Gmail : "smtp.gmsil.com"
Port Gmail : 587


Comments

Popular posts from this blog

รู้จักกับ Breakpoints ใน Responsive Web Design

IS-IS & OSPF

RIP Routing Information Protocol