Trying to send email via vb 2005 win form. I'm able to send email out via Outlook express from this account and I verified everything 100 times, I don't think it's my host email server.
I can't figure out what I'm doing wrong.
Any help?
I've got this code
Private Sub btnSend_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSend.Click
Dim EMsg As New System.Net.Mail .MailMessage
EMsg.From = New MailAddress("To ny@ValidAddress .com")
EMsg.To.Add("To ny@ValidAddress .com")
EMsg.Subject = "this is a test email"
EMsg.Body = "this is the body of the email"
'EMsg.IsBodyHtm l = True
'send the message
Dim smtp As New SmtpClient("htt p://mail.ValidAddre ss.com")
smtp.Credential s = New Net.NetworkCred ential("Tony@Va lidAddress.com" , "ValidPassword" , "mail.ValidAddr ess.com")
Try
smtp.Send(EMsg)
Catch ex As Exception
' MsgBox(ex.ToStr ing)
txtMessage.Text = ex.ToString
End Try
End Sub
I get this Error
System.Net.Mail .SmtpException: Failure sending mail. ---> System.IO.IOExc eption: Unable to read data from the transport connection: net_io_connecti onclosed.
at System.Net.Mail .SmtpReplyReade rFactory.Proces sRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail .SmtpReplyReade rFactory.ReadLi nes(SmtpReplyRe ader caller, Boolean oneLine)
at System.Net.Mail .SmtpReplyReade rFactory.ReadLi ne(SmtpReplyRea der caller)
at System.Net.Mail .SmtpReplyReade r.ReadLine()
at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
at System.Net.Mail .SmtpClient.Get Connection()
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
at EMail.Form1.btn Send_Click(Obje ct sender, EventArgs e) in C:\Documents and Settings\Tony\M y Documents\Visua l Studio 2005\Projects\E Mail\EMail\Form 1.vb:line 20
Thanks
I can't figure out what I'm doing wrong.
Any help?
I've got this code
Private Sub btnSend_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSend.Click
Dim EMsg As New System.Net.Mail .MailMessage
EMsg.From = New MailAddress("To ny@ValidAddress .com")
EMsg.To.Add("To ny@ValidAddress .com")
EMsg.Subject = "this is a test email"
EMsg.Body = "this is the body of the email"
'EMsg.IsBodyHtm l = True
'send the message
Dim smtp As New SmtpClient("htt p://mail.ValidAddre ss.com")
smtp.Credential s = New Net.NetworkCred ential("Tony@Va lidAddress.com" , "ValidPassword" , "mail.ValidAddr ess.com")
Try
smtp.Send(EMsg)
Catch ex As Exception
' MsgBox(ex.ToStr ing)
txtMessage.Text = ex.ToString
End Try
End Sub
I get this Error
System.Net.Mail .SmtpException: Failure sending mail. ---> System.IO.IOExc eption: Unable to read data from the transport connection: net_io_connecti onclosed.
at System.Net.Mail .SmtpReplyReade rFactory.Proces sRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail .SmtpReplyReade rFactory.ReadLi nes(SmtpReplyRe ader caller, Boolean oneLine)
at System.Net.Mail .SmtpReplyReade rFactory.ReadLi ne(SmtpReplyRea der caller)
at System.Net.Mail .SmtpReplyReade r.ReadLine()
at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
at System.Net.Mail .SmtpClient.Get Connection()
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
at EMail.Form1.btn Send_Click(Obje ct sender, EventArgs e) in C:\Documents and Settings\Tony\M y Documents\Visua l Studio 2005\Projects\E Mail\EMail\Form 1.vb:line 20
Thanks
Comment