VS2005 VB.Net SMTPClient with SSL and Authentication

G

Guest

Cannot get the SMTPClient to work with a Smart Host provided by Cable and
Wireless to the NHS in England using SSL and authentication. It works using
Outlook 2003 client and our code works with a W2K3 Virtual SMTP Server
installed here for testing. Also the same code works with our own ISP but
they do not require SSL or authentication.

All we get is a time out before it downloads the SSL certificate.

We have re-written the code to use CDO and that does work with the Cable and
Wireless smart host.

Are there any known issues that we have not found?

The two sets of code are:

1) System.Net.Mail

Dim oMessage As New System.Net.Mail.MailMessage

With oMessage
.From = m_Sender.Sender
.Sender = m_Sender.Sender
.To.Add(m_Recipient)
.DeliveryNotificationOptions = m_DeliveryNotification
.Priority = m_MailPriority
.Subject = m_Subject
.IsBodyHtml = False
.Body = m_Body
End With

Dim oMail As New System.Net.Mail.SmtpClient(m_Host, m_Port)

With oMail
.DeliveryMethod = SmtpDeliveryMethod.Network
.UseDefaultCredentials = False
.EnableSsl = True
Dim oCredCache As New CredentialCache
Dim oCred As New
System.Net.NetworkCredential(m_Credential1.UserName, m_Credential1.Password)
.Credentials = oCred
.Timeout = m_TimeOut
.Send(oMessage)
End With

oMessage.Dispose()

2) Microsoft CDO for Windows 2000

Dim oMessage As New CDO.Message
Dim oConf As New CDO.Configuration

With oConf
.Fields(CDO.CdoConfiguration.cdoSendUsingMethod).Value =
CDO.CdoSendUsing.cdoSendUsingPort
.Fields(CDO.CdoConfiguration.cdoSMTPServer).Value = m_Host
.Fields(CDO.CdoConfiguration.cdoSMTPServerPort).Value = m_Port
.Fields(CDO.CdoConfiguration.cdoSMTPAuthenticate).Value =
CDO.CdoProtocolsAuthentication.cdoBasic
.Fields(CDO.CdoConfiguration.cdoSendUserName).Value = m_UserName
.Fields(CDO.CdoConfiguration.cdoSendPassword).Value = m_Password
.Fields(CDO.CdoConfiguration.cdoSMTPUseSSL).Value = True
.Fields.Update()
End With

With oMessage
.Configuration = oConf
.From = m_Sender
.To = m_Recipient
.Subject = m_Subject
.TextBody = m_Body
.Send()
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top