Mark Tabor

Mark Tabor

  • 581
  • 2k
  • 464.9k

Send email using my own domain hosting server

Jul 26 2016 2:26 AM
I have below method i am sending email to [email protected] using my own domain email server i have taken details from the hosting provider below is my method it gives an exception "Failure sending mail." when i go into the innner message it says could not connect to the server my credentials are 100% correct .
Private Sub SendEmail()
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/><br/>" & Environment.NewLine
MailText = MailText + "<font face='verdana' color='#000000'>" + " " & "we are glad to inform you that your records has accepted.</font>" & "<br/> ""<font Face='Verdana' font-size:14px;Color='#000000'><b><br/>" + AcceptComments & """</font> " + Environment.NewLine
MailText = MailText + "<font Face='Verdana' font-size:14px;Color='#000000'><b><br/>" & " Regards," & " " & "<br/>" & "<i>Plan Pakistan RBME TEAM<i>" + "</b></font>" & vbCrLf
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.To.Add(GetUserIDEmail(ddlusers.SelectedValue))
Mail.From = New MailAddress("[email protected]")
Dim smtp As New SmtpClient("venus.hostingmadeeasy.com")
smtp.EnableSsl = False
smtp.Credentials = New System.Net.NetworkCredential("[email protected]", "pakistan")
smtp.Port = 25
smtp.Send(Mail)
Catch ex As Exception
ex.Message.ToString()
End Try
End Sub
 

Answers (7)