Sending an email from ASP.Net using VB

  • Thread starter Thread starter Rob Meade
  • Start date Start date
....and hating the ctrl-enter key combination - my appologies - I'll try
again...

I am using the following code:

' Send email
Dim objEmail As New MailMessage
objEmail.To = "(e-mail address removed)"
objEmail.From = "(e-mail address removed)"
objEmail.Subject = "Enquiry"
objEmail.Body = strEmailBody
objEmail.Priority = MailPriority.High
SmtpMail.SmtpServer = "localhost"

Try
SmtpMail.Send(objEmail)
panelContactUsForm.Visible = False
panelContactUsThanks.Visible = True
panelContactUsError.Visible = False
Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
panelContactUsForm.Visible = False
panelContactUsThanks.Visible = False
panelContactUsError.Visible = True
End Try

This is working fine and I am receiving emails nicely on my development
server here. What I've found odd is that I can't seem to prevent an email
coming through! I shall explain..

I looked in IIS but found no "Default SMTP Server" like I used to on Windows
2000 (now using Windows 2003) - I believe this gets added to the ISM when
you set the role as a Mail Server, however, enough components from the CD
have been installed to enable email quite obviously. So, I figured the best
way to stop the service was to go into Services, find the Simple Mail
Transfer Protocol service and stop it - I did this, I waited a bit and then
tried my application again - I received an email!

So, kinda confused now - I want to test that my exception handling works, I
can obviously knock out the objEmail.To = line and change it to something
daft, which might work, but I dont understand why I'm getting emails when as
far as I can see I shouldn't be...

Any information would be appreciated,

Regards

Rob Meade
I
 
Ok - I installed MailEnable (www.mailenable.com) a few weeks back, forgot it
was running, it would seem that my server had a choice of SMTP services to
use, couldn't perhaps use the normal one so used MailEnable instead...I
stopped ALL of those services, and the SMTP one and got the expected error
message...

Sorry to bother...

Regards

Rob
 
Back
Top