Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. About Mail

About Mail

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kheer
    wrote on last edited by
    #1

    Hi every one I am a beginner in ASP.NET I am working on sending Email, but unable to get it... I am screwed up........., i have tried many codes in google but i am confused. Please any one can give me steps to follow from beginning to end. :|

    S A 2 Replies Last reply
    0
    • K kheer

      Hi every one I am a beginner in ASP.NET I am working on sending Email, but unable to get it... I am screwed up........., i have tried many codes in google but i am confused. Please any one can give me steps to follow from beginning to end. :|

      S Offline
      S Offline
      simsen
      wrote on last edited by
      #2

      Hi kiranreddy, Try this:

      using System.Net.Mail;
      protected void btnSendMessage_Click(object sender, EventArgs e)
      {
      SmtpClient smtpClient = new SmtpClient();
      MailMessage message = new MailMessage();

      try
      {

          MailAddress fromAdress = new MailAddress("YourSenderEmail", "NameThatSendTheMessage");
      
          smtpClient.Host = "YoursmptClientHost";
      
          smtpClient.Port = 25; //Which port the smtpClient sends on
      
          message.From = fromAdress;
      
          message.To.Add("MailAdressToWhoShouldRecieveTheMail");
          message.Subject = "The message subject";
      
          message.IsBodyHtml = false;
      
          message.Body = "The message went here";
      
          smtpClient.Send(message);
          lblSendOk.Visible = true;
      }
      catch (Exception ex)
      {
          //Here I show an error, if any
          lblSendError.Visible = true;
          lblSendError.Text = lblSendError.Text + " .<br />" + ex.Message;
      }
      

      }

      If you have any trouble with the above code, you have to tell what exactly the error gives and copy your code, so we can see, if you have done anything else. Kind regards, simsen :-)

      1 Reply Last reply
      0
      • K kheer

        Hi every one I am a beginner in ASP.NET I am working on sending Email, but unable to get it... I am screwed up........., i have tried many codes in google but i am confused. Please any one can give me steps to follow from beginning to end. :|

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        you have to use System.Net namesapce and use MailMessage Class.

        cheers, Abhijit

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups