spiraljonny
asked on
SMTP Client - 'The SMTP host was not specified"
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
Dim smtpServer As SmtpClient
smtpServer = New SmtpClient()
smtpServer.Send(emailMessa
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
http://forums.msdn.microsoft.com/en-US/csharpgeneral/thread/4ab25de2-4278-4d62-b2c1-c4dfc8975605/