.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Sending Mails

Posted By:Karthikeyan Anbarasan       Posted Date: December 29, 2010    Points: 15    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Sending mails from pages

MailMessage msg = new MailMessage();
    msg.From = new MailAddress("example@gmail.com", "email");

    msg.To.Add(new MailAddress("email@example.com", "email 2"));
    msg.Priority = MailPriority.High;

    msg.Subject = "test!";
    msg.Body ="Mail body here";
    msg.IsBodyHtml = true;

    msg.Attachments.Add(new Attachment("C:\\demo.txt"));

    SmtpClient client = new SmtpClient();
    client.Host = "smtp.gmail.com";
    client.Port = 578;
    client.EnableSsl = true;
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential("email@abc.com", "demo");
    client.DeliveryMethod = SmtpDeliveryMethod.Network;


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend