I'm trying to add an e-mail send utility to my VB program, but not having much luck.
I'm using Visual Studio 2005, and I have added Imports System.Net.Mail to the module.
Here's my code :
Dim objSmtpClient As SmtpClient
Dim objMailMessage As MailMessage
Dim objMailAddress As MailAddress
objSmtpClient = New SmtpClient
objMailAddress = New MailAddress("myname@mycompany.com")
objMailMessage = New MailMessage(objMailAddress, objMailAddress)
objMailMessage.Subject = "test"
objMailMessage.Body = "test"
objSmtpClient.Host = "<smtp host name>"
objSmtpClient.Port = 25
Call objSmtpClient.Send(objMailMessage)
The Send method fails with the following error :
{"Unable to connect to the remote server"}
{"No connection could be made because the target machine actively refused it"}
I verified the SMTP host settings with our mail server specialist. He told me that it should not be necessary to use credentials when sending e-mails internally, as our servers allow anonymous requests.
Anybody have any advice on why the send method is failing?
I'm using Visual Studio 2005, and I have added Imports System.Net.Mail to the module.
Here's my code :
Dim objSmtpClient As SmtpClient
Dim objMailMessage As MailMessage
Dim objMailAddress As MailAddress
objSmtpClient = New SmtpClient
objMailAddress = New MailAddress("myname@mycompany.com")
objMailMessage = New MailMessage(objMailAddress, objMailAddress)
objMailMessage.Subject = "test"
objMailMessage.Body = "test"
objSmtpClient.Host = "<smtp host name>"
objSmtpClient.Port = 25
Call objSmtpClient.Send(objMailMessage)
The Send method fails with the following error :
{"Unable to connect to the remote server"}
{"No connection could be made because the target machine actively refused it"}
I verified the SMTP host settings with our mail server specialist. He told me that it should not be necessary to use credentials when sending e-mails internally, as our servers allow anonymous requests.
Anybody have any advice on why the send method is failing?