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)
MailServer.Send(Message)

Any help would be great

Thanks
LVL 1
hendrix500Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
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.
0
É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).

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hendrix500Author Commented:
Thanks for your help
0
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.