Emailing from website is not working.

Discussion in 'Visual Studio' started by jluft2131, Jul 13, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hey everyone,

    I've been stuck trying to figure out why my emailing wont work and its had me trying a million different things and nothing works. This is my current code for when the submit button gets fired.

    Dim mailMessage As MailMessage = New MailMessage()
    mailMessage.From = New MailAddress("[email protected]")
    mailMessage.To.Add(New MailAddress("[email protected]"))
    mailMessage.Priority = MailPriority.High
    mailMessage.Subject = "test subject"
    mailMessage.BodyEncoding = Encoding.Default
    mailMessage.Body = txtMessage.Text.Trim()
    mailMessage.IsBodyHtml = False

    Dim smtpClient As SmtpClient = New SmtpClient()

    Try
    smtpClient.Send(mailMessage)
    Catch smtopExc As SmtpException
    'Log errors
    Catch ex As Exception
    'Log errors
    End Try


    I also have some values in the web.config file. They are as follows.

    <system.net>
    <mailSettings>
    <smtp>
    <network host="localhost" password="" userName=""/>
    </smtp>
    </mailSettings>
    </system.net>


    I am getting an error on my debug output that says

    "A first chance exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
    The program '[5208] WebDev.WebServer.EXE: Managed' has exited with code 0 (0x0).
    "

    Any ideas??:mad:
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    are you getting this error on our server? It doesn't look like an IIS error.
     
  3. Hey bruce, thanks for trying to help.

    I'm not sure how to test it on that server...

    Can you give me steps on how to do so?

    Do i just need to change server from localhost to something else?
     
  4. Are you saying to actually put it up on my site as it?
     
  5. mjp

    mjp

    I think he was trying to determine where you were running the code, since the error is not an IIS error. Your title for the thread suggested the code was on the server, but apparently it isn't.

    It's more likely that we can help if you're running into problems on our servers. Less likely if you're running an application in your local dev environment.
     
  6. okay, I will put the code up and you guys will actually be able to see it up on my site. I still need to leave the host as "localhost" tho correct? The code to send the e-mail gets fired when you click the finish button at the end of my contact form
     
  7. wowww you guys were right! excellent! thanks a lot
     
  8. mjp

    mjp

    Cool, glad it's working for you.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page