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(emailMessa
ge)
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