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. Email Sending...Help!!!

Email Sending...Help!!!

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netvisual-studio
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.
  • D Offline
    D Offline
    DaithiBoo
    wrote on last edited by
    #1

    Hi guys :) i am developing a website in ASP.NET using vb.net in the visual studios 2008 IDE. I am attempting to send an email from my website. i keep getting a "sending message failure" on my site. here is my code. hopefully somebody can be of assistance. much help appreciated. ContactUs.aspx.vb: Partial Class Default2 Inherits System.Web.UI.Page Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() mailMessage.From = New System.Net.Mail.MailAddress(txtFromAddress.Text.Trim()) mailMessage.To.Add(New System.Net.Mail.MailAddress(txtToAddress.Text.Trim())) mailMessage.Subject = txtSubject.Text.Trim() mailMessage.Body = txtBody.Text.Trim() Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient() smtpClient.Send(mailMessage) *THIS IS WHERE THE ERROR SHOWS UP WHEN I CLICK SEND*:confused::confused::confused: End Sub Here is my web.config file code: <system.net> <mailSettings> <smtp> <network host="localhost"/> </smtp> </mailSettings> </system.net> End Class thanks in advance!! :) Daithi

    N R 2 Replies Last reply
    0
    • D DaithiBoo

      Hi guys :) i am developing a website in ASP.NET using vb.net in the visual studios 2008 IDE. I am attempting to send an email from my website. i keep getting a "sending message failure" on my site. here is my code. hopefully somebody can be of assistance. much help appreciated. ContactUs.aspx.vb: Partial Class Default2 Inherits System.Web.UI.Page Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() mailMessage.From = New System.Net.Mail.MailAddress(txtFromAddress.Text.Trim()) mailMessage.To.Add(New System.Net.Mail.MailAddress(txtToAddress.Text.Trim())) mailMessage.Subject = txtSubject.Text.Trim() mailMessage.Body = txtBody.Text.Trim() Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient() smtpClient.Send(mailMessage) *THIS IS WHERE THE ERROR SHOWS UP WHEN I CLICK SEND*:confused::confused::confused: End Sub Here is my web.config file code: <system.net> <mailSettings> <smtp> <network host="localhost"/> </smtp> </mailSettings> </system.net> End Class thanks in advance!! :) Daithi

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Format the code you have posted according to the guidelines. I will only answer questions that have been properly formatted


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • D DaithiBoo

        Hi guys :) i am developing a website in ASP.NET using vb.net in the visual studios 2008 IDE. I am attempting to send an email from my website. i keep getting a "sending message failure" on my site. here is my code. hopefully somebody can be of assistance. much help appreciated. ContactUs.aspx.vb: Partial Class Default2 Inherits System.Web.UI.Page Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() mailMessage.From = New System.Net.Mail.MailAddress(txtFromAddress.Text.Trim()) mailMessage.To.Add(New System.Net.Mail.MailAddress(txtToAddress.Text.Trim())) mailMessage.Subject = txtSubject.Text.Trim() mailMessage.Body = txtBody.Text.Trim() Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient() smtpClient.Send(mailMessage) *THIS IS WHERE THE ERROR SHOWS UP WHEN I CLICK SEND*:confused::confused::confused: End Sub Here is my web.config file code: <system.net> <mailSettings> <smtp> <network host="localhost"/> </smtp> </mailSettings> </system.net> End Class thanks in advance!! :) Daithi

        R Offline
        R Offline
        Rutvik Dave
        wrote on last edited by
        #3

        There is nothing wrong with the code, but you havent setup your smtp server. you are using <network host="localhost"/> where smtp is not setup. so either use your company email server i.e. mail.yourcompanydomain.com if you dont have smtp server setup at your company, then you can use Gmail, just create an account on gmail and you can use smtp.gmail.com as your stmp server with the user name and password that you have created. use the following example...

            public static void CreateTestMessage1(string server, int port)
            {
                string to = "someone@somewhere.com";
                string from = "me@somewhere.com";
                string subject = "Using the new SMTP client.";
                string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
                MailMessage message = new MailMessage(from, to, subject, body);
                SmtpClient client = new SmtpClient("smtp server name");
        
                client.Credentials = new System.Net.NetworkCredential("username", "password");
        
          try {
                  client.Send(message);
          }
                catch (Exception ex) {
                  Console.WriteLine("Exception caught in CreateTestMessage1(): {0}", 
                        ex.ToString() );
          }              
            }
        

        also as Mark said, please use the code block feature when you post a code in your question. :)

        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