Send email through a SMTP Server that requires authentication

  • Thread starter Thread starter Rodrigo
  • Start date Start date
R

Rodrigo

I'm trying to send an email message using my SMTP server
that requires authentication. How can I do that? My code
is:
Dim email As System.Web.Mail.MailMessage = New
System.Web.Mail.MailMessage
email.From = "(e-mail address removed)"
email.To = txtemail.Text
email.Subject = "We have receveid your comments"
email.BodyFormat = System.Web.Mail.MailFormat.Html
email.Body ="<html>" & _
"<head>" & _
"<title>Untitled Document</title>" & _
"</head>" & _
"<body>" & _
"<p><font color=""#0066FF"" size=""2""
face=""Arial, Helvetica, sans-serif"">Hi,</font></p>" & _
"<p><font color=""#0066FF"" size=""2""
face=""Arial, Helvetica, sans-serif"">You are welcome! " &
_
"</font></p>" & _
"<p><font color=""#0066FF"" size=""2""
face=""Arial, Helvetica, sans-serif"">Thanks,</font></p>"
& _
"<p>&nbsp;</p>" & _
"<p><font color=""#0066FF"" size=""2""
face=""Arial, Helvetica, sans-serif"">Me.</font></p>" & _
"</body>" & _
"</html>"

System.Web.Mail.SmtpMail.SmtpServer
= "smtp.mydomain.com.br"

System.Web.Mail.SmtpMail.Send(email)

Response.Redirect("cad_ok.aspx")

And I receive this error message:

System.Runtime.InteropServices.COMException: The transport
failed to connect to the server.

Thanks in advance,
Rodrigo
 
The native .NET classes do not support authentication when sending messages.
You will have to find/buy a 3rd party component that does.
 
Back
Top