Stephen Ford

Stephen Ford

  • NA
  • 5
  • 1.8k

Unable to send email in Visual Web Developer 2010 VB

Aug 30 2012 3:55 AM
I am using Visual Web Developer 2010 and Visual Basic with NET version 4. I want to send an email from a web page I have Created. I have referenced System.Net from the Solution Explorer References page. The code runs without error but no email message is sent. Below is a copy of the code.

Imports System.Net.Mail

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

        Dim mm As New System.Net.Mail.MailMessage("my email address", "recipients email address")
        mm.IsBodyHtml = True
        mm.Body = "<h1>Hello World</h1>"
        mm.Subject = "Test"
        Dim client As New System.Net.Mail.SmtpClient("Service provider smtp address")
        client.Credentials = New System.Net.NetworkCredential("my user name", "my password")
        client.Send(mm)
        Dispose()

    End Sub

Any help or suggestions would be greatly appreciated.

Many thanks

Steve

Answers (4)