• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Emailing from VB.NET APP

Hi everyone.

I have a problem sending emails from my vb.net program. It is fine sending to email address's on our domain, but doesn't work if I try and send to an external address e.g. hotmail account. No error is reported, the email is just never recieved.

Code is as follows:

Dim Message As New System.Web.Mail.MailMessage
With Message
    .To = "<myexternaladdress@hotmail.co.uk>"
    .From = "<myapp@mydomain.co.uk>"
     .Body = "My test mail"
     .Subject = "My subject"
End With

Dim MailServer As System.Web.Mail.SmtpMail
MailServer.SmtpServer = "555.555.555.5"   'IP of my exchange server (version 5.5 sp2)

Any help would be great

  • 2
2 Solutions
Check the SMTP server logs on:

>>>MailServer.SmtpServer = "555.555.555.5"

I suspect that for some reason it is configured NOT to permit relaying of email from your web server to the outside world.  The logs should show the problem.

Also, are you sure there is no error?  How about checking for an error in your VB.NET code?  SmtpMail throws a System.Web.HttpException.  You don't seem to be catching that exception.
Éric MoreauSenior .Net ConsultantCommented:
Hi hendrix500,

> It is fine sending to email address's on our domain, but doesn't work
> if I try and send to an external address

Your sysadmin had stopped relay. They all do that because of spamming. You should have him install a SMTP server that is not available from the outside (but will be able to send e-mails outside).

hendrix500Author Commented:
Thanks for your help
hendrix500Author Commented:
Both answers were correct. I awarded slighlty in favour of emoreau because of the suggestion to install a SMTP server.

Thanks alot to both

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now