Mark Tabor

Mark Tabor

  • 548
  • 2k
  • 460.4k

SmtpClient.EnableSsl Property in asp.net

Jul 21 2016 6:52 AM
I have purchased a hosting with domain registration now i want to use my company mail account to send an email like [email protected] , below is my code 
--------------------------------------------------------------------------------------------------------
Private Sub SendEmail()
'These twos are commented on Morning on 2/5/2014
GetUserIDEmail(Session("LoggedInUserId"))
' GetEmailAddressOfReporintUser(Hdm.Value)
' Using mailMessage As New MailMessage()
Dim Mail As New MailMessage
Try
Mail.IsBodyHtml = True
Dim MailText As String = Nothing
Mail.Subject = " Report Submitted By : " & Session("LoggedInUserFullName") & " " & "User Type:" & GetUserTypeName(CInt(Session("UserTypes")))
MailText = MailText + "<font face='verdana' color='#000000'>" & "Dear User, " & "</font><br/>
Mail.IsBodyHtml = True
Mail.Body = MailText
Dim files As List(Of HttpPostedFile) = DirectCast(Cache(Me.Key), List(Of HttpPostedFile))
For Each file As HttpPostedFile In files
Mail.Attachments.Add(New Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType))
Next
Mail.From = New MailAddress("[email protected]")
Dim smtp As New SmtpClient("venus.hostingmadeeasy.com")
smtp.EnableSsl = true
smtp.Credentials = New System.Net.NetworkCredential("[email protected]", "pakistan")
smtp.Port = 25
Catch ex As Exception
ex.Message.ToString()
End Try
End Sub
 
 
My code run ok when i made smtp.Enab,eSsl=false but when i select it to true it gives an error as mentioned below
server does not support secure connections. smtp exception 

Answers (1)