Subscribe Now!

Enter your email address:

Monday, September 7, 2015

Send a Email Using Asp.net and C#

  protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.sa"));
                //message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

                message.Body = "Drug Name : " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text; //Body Of Email Content
                SmtpClient client = new SmtpClient();
                client.Host = "10.10.180.102";
                client.Send(message);
            }
        }




Add this Name Space in C#:

using System.Net.Mail;


Call this method in Button or any kind of Form to send Email....


Send a Email Using Asp.net and C#

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...