I'm new to .NET 2 and am having real difficulty with emails getting stuck in my mailroot\queue folder. I'm running Windows 2000 SP4 with IIS5, and have configured a virtual SMTP server, and allowed my "localhost" (127.0.0.1) to
connect & relay to this server.
I have a contact form (in a test website on my PC) created from several TextBox'es. The code-behind file has the following:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SendTo As String = "my-email@my-domain.com"
Dim Subject As String = "Subject ..."
'Name, company, etc come from form on webpage...
Dim Message As String
Message = "Message from: " & Name.Text & vbCrLf _
& "Company Name: " & Company.Text & vbCrLf _
& "Telephone: " & Tel.Text & vbCrLf & vbCrLf _
& "Enquiry: " & vbCrLf & Enquiry.Text
Dim MailObj As New System.Net.Mail.SmtpClient()
MailObj.Host = "localhost"
Try
MailObj.Send(Email.Text, SendTo, Subject, Message)
Label8.Text = "Thankyou. Your message has been sent."
Catch ex As Exception
Label8.Text = ex.Message
End Try
End Sub
My web.config contains:
<system.net>
<mailSettings>
<smtp from="my-email@my-domain.com">
<network host="localhost" password="" userName="" />
</smtp>
</mailSettings>
</system.net>
On clicking submit, I get no errors / exceptions, but the email just sits in the queue. SMTP logs show no errors. I've tried changing host to my ISP and using their SMTP server details (with & without authentication) and specifying a smart host too... all to no avail.
Feel like I'm going round in circles!
Can anyone assist?