Emailing from VB.NET APP

Posted on 2006-03-27
Last Modified: 2010-04-17
Hi everyone.

I have a problem sending emails from my 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 = "<>"
    .From = "<>"
     .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

Question by:hendrix500
    LVL 32

    Assisted Solution

    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.
    LVL 69

    Accepted Solution

    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).

    LVL 1

    Author Comment

    Thanks for your help
    LVL 1

    Author Comment

    Both answers were correct. I awarded slighlty in favour of emoreau because of the suggestion to install a SMTP server.

    Thanks alot to both

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    java constructor error 8 63
    wordsWithoutList  challenge 24 61
    wordappend challenge 8 45
    wordmultiple challenge 12 62
    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now