Ch 11 SMTP SendMail Authentication Required
My mail service requires authentication (i.e. name & password) before it will accept and send an email. The code for sending an email on pages 236-7 is missing a two statements.
First, you need to add a second Imports statement for namespace System.Net in addition to the one for System.Net.Mail. Put put both these Import statements above the POMessage class definition.
Second, you need to populate the credentials before calling Send:
Dim MyMailServer As New SmtpClient()
With MyMailServer
.Host = "your.smtp.host.goes.here"
.Credentials = New NetworkCredential("UserName", "pswd")
.Send(POMessage)
End With
MessageBox.Show("Message sent")
After adding these two statements, the sendmail procedure worked for me. There is a third variable, domain, that can be set in NetworkCredential. My ISP (verizon.net) required that item to be left empty (null). Your provider may have different requirements.
hit 'em straight,
MR
|