473,385 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VS2005 VB.Net SMTPClient with SSL and Authentication

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.UserNam e, 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).V alue =
CDO.CdoSendUsing.cdoSendUsingPort
.Fields(CDO.CdoConfiguration.cdoSMTPServer).Value = m_Host
.Fields(CDO.CdoConfiguration.cdoSMTPServerPort).Va lue = m_Port
.Fields(CDO.CdoConfiguration.cdoSMTPAuthenticate). Value =
CDO.CdoProtocolsAuthentication.cdoBasic
.Fields(CDO.CdoConfiguration.cdoSendUserName).Valu e = m_UserName
.Fields(CDO.CdoConfiguration.cdoSendPassword).Valu e = 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

Jul 12 '06 #1
1 3185
This has been reposted to microsoft.public.vsnet.general on advice from MS.

"Charles Waudby" <Ch***********@discussions.microsoft.comwrote in message
news:22**********************************@microsof t.com...
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.UserNam e,
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).V alue =
CDO.CdoSendUsing.cdoSendUsingPort
.Fields(CDO.CdoConfiguration.cdoSMTPServer).Value = m_Host
.Fields(CDO.CdoConfiguration.cdoSMTPServerPort).Va lue = m_Port
.Fields(CDO.CdoConfiguration.cdoSMTPAuthenticate). Value =
CDO.CdoProtocolsAuthentication.cdoBasic
.Fields(CDO.CdoConfiguration.cdoSendUserName).Valu e =
m_UserName
.Fields(CDO.CdoConfiguration.cdoSendPassword).Valu e =
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

Jul 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
by: Rob Dob | last post by:
VS2005 is a PIECE of Garbage and is bug Ridden, I wonder how many others feel the same, I am so sorry that I have moved away from VS2003, VS2005 is unstable, and half the stuff doesn't work, ...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
10
by: David Thole | last post by:
Hey all, I'm still very new at all this, but am going through the ASP.net 2.0 unleashed book, first chapter and trying to program my own little form emailer for fun. I tried following the code...
4
by: | last post by:
Hi all, We are using the Asp.Net SMTP Client to send email via our Exchange 2003 SP2 Server. When trying to send email to a local recipient I am getting the following error:- Server:...
16
by: =?Utf-8?B?Q2hlZg==?= | last post by:
I can use outlook2003 to send email,but I cann't use this code below to send email. Please help me to test this code and instruct me how to solve this problem in detail. software...
0
by: fred64 | last post by:
Hello , I fought very hard and succeed to do a remote debug from a client with VS2003 on XP HOME to a Server with XP PRO. This is on a Workgroup : I created same user/pwd with admin rights...
6
by: =?Utf-8?B?VG9yc3Rlbg==?= | last post by:
Hi, I have a problem sending mails with the SmtpClient class. It's strange - after I boot the pc and start the program I can send mails many times. After I close the program and start it again...
7
by: Afshar | last post by:
Dear Friends, I want to send email but don't wanna use SmtpClient class, because I want more control on generated mail. Is there any good alternative? Thanks In Advance
5
by: BigDave | last post by:
Hi, I'm having problems with SmtpClient. I have the following set in my web.config: <configuration> <system.net> <mailSettings> <smtp> <network host="mysmtp" port="25" userName="myuser"
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.