UKmedia
Programmer
- Nov 2, 2002
- 90
Afternoon,
I am finding it difficult to send an email via a asp.net project I am working on. I have posted the code I am using below
When it fires it is not doing anything nor given an error. Am I doing this correctly?
UKmedia productions
I am finding it difficult to send an email via a asp.net project I am working on. I have posted the code I am using below
Code:
Dim mMailServer As String
Dim mTo As String
Dim mFrom As String
Dim mMsg As String
Dim mSubject As String
Dim mPort As Integer
mTo = Trim("richard.thatcher@gmail.com")
mFrom = Session("Email")
mSubject = Trim(txtSubject.Text)
mMsg = Trim(txtMessage.Text)
mMailServer = ("no-auth.no-ip.com")
mPort = (25)
Try
Dim message As New MailMessage(mFrom, mTo)
Dim SmtpClient As New SmtpClient(mMailServer)
message.Subject = mSubject
message.Body = mMsg
message.IsBodyHtml = False
SmtpClient.Credentials = New System.Net.NetworkCredential("sean@gardiff.com", "654a32")
SmtpClient.Send(message)
MessageBox("The mail message has been sent to " & mTo)
Catch ex As FormatException
MessageBox("Format Exception: " & ex.Message)
Catch ex As SmtpException
MessageBox("SMTP Exception: " & ex.Message)
Catch ex As Exception
MessageBox("General Exception: " & ex.Message)
End Try
lblMessage.Text = "Message Sent"
End Sub
When it fires it is not doing anything nor given an error. Am I doing this correctly?
UKmedia productions