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. Sending mail from asp.net.. need help

Sending mail from asp.net.. need help

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomsysadminhelp
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.
  • H Offline
    H Offline
    Hema Bairavan
    wrote on last edited by
    #1

    Hi peoples, i m trying to send an mail from my application (localhost) this is my code..( i copied from website) // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient("localhost"); // Specify the e-mail sender. // Create a mailing address that includes a UTF8 character // in the display name. MailAddress from = new MailAddress("hbairavan@yahoo.com", "Jane " + (char)0xD8 + " Clayton", System.Text.Encoding.UTF8); // Set destinations for the e-mail message. MailAddress to = new MailAddress("hbairavan@yahoo.com"); // Specify the message content. System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to); message.Body = "This is a test e-mail message sent by an application. "; // Include some non-ASCII characters in body and subject. string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192', '\u2193' }); message.Body += Environment.NewLine + someArrows; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = "test message 1" + someArrows; message.SubjectEncoding = System.Text.Encoding.UTF8; // Set the method that is called back when the send operation ends. client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); // The userState can be any object that allows your callback // method to identify this send operation. // For this example, the userToken is a string constant. string userState = "test message1"; client.EnableSsl = false; client.UseDefaultCredentials = false; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential(from.ToString(), "f00bar"); client.SendAsync(message, userState); after this line am getting exception that failure sending mail.. wat may be the reason.please help \ thanks in advacnce

    A 1 Reply Last reply
    0
    • H Hema Bairavan

      Hi peoples, i m trying to send an mail from my application (localhost) this is my code..( i copied from website) // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient("localhost"); // Specify the e-mail sender. // Create a mailing address that includes a UTF8 character // in the display name. MailAddress from = new MailAddress("hbairavan@yahoo.com", "Jane " + (char)0xD8 + " Clayton", System.Text.Encoding.UTF8); // Set destinations for the e-mail message. MailAddress to = new MailAddress("hbairavan@yahoo.com"); // Specify the message content. System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to); message.Body = "This is a test e-mail message sent by an application. "; // Include some non-ASCII characters in body and subject. string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192', '\u2193' }); message.Body += Environment.NewLine + someArrows; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = "test message 1" + someArrows; message.SubjectEncoding = System.Text.Encoding.UTF8; // Set the method that is called back when the send operation ends. client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); // The userState can be any object that allows your callback // method to identify this send operation. // For this example, the userToken is a string constant. string userState = "test message1"; client.EnableSsl = false; client.UseDefaultCredentials = false; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential(from.ToString(), "f00bar"); client.SendAsync(message, userState); after this line am getting exception that failure sending mail.. wat may be the reason.please help \ thanks in advacnce

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

      Hema Bairavan wrote:

      // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient("localhost");

      You have putted "localhost" as your SMTP Server name. I guess this is wrong. Does your SMTP Server configured properly. What is the name of the Server ? Try This link. http://support.microsoft.com/kb/323436[^]

      Hema Bairavan wrote:

      after this line am getting exception that failure sending mail..

      Please check your server configuration as I have suggested. Thanks !

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      F 1 Reply Last reply
      0
      • A Abhijit Jana

        Hema Bairavan wrote:

        // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient("localhost");

        You have putted "localhost" as your SMTP Server name. I guess this is wrong. Does your SMTP Server configured properly. What is the name of the Server ? Try This link. http://support.microsoft.com/kb/323436[^]

        Hema Bairavan wrote:

        after this line am getting exception that failure sending mail..

        Please check your server configuration as I have suggested. Thanks !

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        F Offline
        F Offline
        farogh haider
        wrote on last edited by
        #3

        Hi, If you are sending your mail via system.net.mail. you should use smtp server ip or smtp server name and should be configured properly on server.

        Farogh Haider Web developer

        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