How to use System.Net.Mail.SmtpClient via SSL and Authentication?

G

Guest

Below is my code, and is just blocked there. There is no any error message.

'=============================================>
Dim msg As String = "---"
Try
Dim strFrom As String = "(e-mail address removed)"
Dim sm As New SmtpClient(Host, Port)
With sm
.EnableSsl = True
.Credentials = New NetworkCredential("MyuserName", "MyPass")
End With

Dim _from As MailAddress = New MailAddress(str)
Dim _to As MailAddress = New MailAddress(str)
Dim mMsg As New MailMessage(_from, _to)
mMsg.Subject = "Happy AAA"
'mMsg.SubjectEncoding = System.Text.Encoding.UTF8

sm.Send(mMsg)

msg = "Seccess!"
Catch ex As Exception
msg = ex.Message
End Try

TextBox1.Text = msg

'<<=================================================

Thanks for any suggestion.
 

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

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top