Pages

Subscribe:

Ads 468x60px

Thursday, March 8, 2012

how to send email in asp.net using c#

In this web programming tutorial we will learn that how we can send email in asp.net using c#.
In order to do so we need to do following steps.


add below name space in your aspx.cs file
using System.Net.Mail;
mail sending function in .cs file.

public void sendmail()
    {
        MailMessage Message = new MailMessage("abc@test.com", "abcd@test.com");        
        Message.CC.Add("abc@test.com");
        Message.Bcc.Add("test@test.com");
        Message.IsBodyHtml = true;
        Message.Subject = "Email Subject will goes here";
        Message.Body = "Mail body will goes here";      
        SmtpClient S1 = new SmtpClient();
        try
        {
            S1.Send(Message);
        }
        catch (Exception Exp)
        {
            throw Exp;
        }
    }
code for web.config file in Configuration section

    
     
 
     
 
  

No comments:

Post a Comment