Advertisement

06.12.2008 at 07:50AM PDT, ID: 23479693
[x]
Attachment Details

SMTP Client - 'The SMTP host was not specified"

Asked by spiraljonny in Microsoft Visual Basic.Net, Visual Studio .NET 2005, .NET Framework 2.0

Tags: Microsoft, VB.Net, 2005

I am trying to send an email using the SMTPClient class but I keep getting the 'SMTP host was not specified error'. This is the code:
                    Dim smtpServer As SmtpClient
                    smtpServer = New SmtpClient()
                    smtpServer.Send(emailMessage)
                    smtpServer = Nothing
where emailMessage is an object of type MailMessage and is populated earlier in the function.
 
When I instantiate the object like this:
     smtpServer = New SmtpClient("our.host")
it works correctly.

As I understand it, the SMTPClient should obtain the host from the config file:
<configuration>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network">
        <network host="our.host"/>
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

The config file also contains system.diagnostic and runtime settings which I've left out for clarity.

Incidentally the framework is 2.0.

Any help would be much appreciated


Start Free Trial
 
 
[+][-]06.12.2008 at 08:35AM PDT, ID: 21770633

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.13.2008 at 02:32AM PDT, ID: 21777191

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Visual Studio .NET 2005, .NET Framework 2.0
Tags: Microsoft, VB.Net, 2005
Sign Up Now!
Solution Provided By: spiraljonny
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628