Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Thursday, September 11, 2008

Sending Email Using ASP.Net 2.0


Sending Email Using ASP.Net 2.0
Add Belowe Name Space to Access All Class and Methods Which Are Needed for Sending Mail.
using System.Net.Mail;
Write Down Following Code on Button Click
MailMessage msg = new MailMessage();
msg.From = new MailAddress("youaddress@yourdomain.com");
msg.To.Add(new MailAddress("sent@domain.com"));
msg.Subject = "Message Subject";
msg.Body = "Mail body content";
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
SmtpClient c = new SmtpClient("domain smtp server");
c.Credentials = new System.Net.NetworkCredential("user@domain.com", "userpassword");
c.Send(msg);
While Developing and Testing this Module there are Verious Problem Exisits it's mainly Security and SMTP Configuration
Related if you Found any Problem then let me know that Once.


Prev Post                                                      All Post                                                           Next Post


3 comments:

  1. Using CDOSYS the mail sending is very simple

    Add a reference of the Microsoft CDO for windows 2000 library in the solution

    right click in the solution bin folder-->Add reference -->Select COM tab --> and click on Microsoft CDO for windows 2000 library




    private void SendEmail()
    {
    try
    {
    Message msg = new MessageClass();
    msg.From = "sreenathviswas@gmail.com";


    msg.To = "sreenath@quazio.org";
    msg.Subject = "Your Subject";
    msg.TextBody = "Your Message Body"
    msg.Send();
    }
    catch (Exception ex)
    {
    throw ex;
    }

    }

    ReplyDelete
  2. Nice Coding Suggestion SREENATH

    but i am thinking in ASP.net 2.0 Sending mail using System.Net.mail is efficient.

    Are you use this code in Asp.net 1.1 ?

    ReplyDelete
  3. to Access Messageclass include foloowing namespace.

    using CDO;

    ReplyDelete