vb 2005 email

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Mastracchio

    #1

    vb 2005 email

    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
  • Ken Tucker [MVP]

    #2
    Re: vb 2005 email

    Tony,

    You smtp server is wrong it should be something like this.

    Dim smtp As New SmtpClient("mai l.ValidAddress. com")
    smtp.Credential s = New Net.NetworkCred ential("Tony@Va lidAddress.com" ,
    "ValidPassword" , "mail.ValidAddr ess.com")

    Ken
    ----------------------

    "Tony Mastracchio" <TonyMast@MSN.C om> wrote in message
    news:uPL158yLGH A.3196@TK2MSFTN GP09.phx.gbl...
    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


    Comment

    • Carlos J. Quintero [VB MVP]

      #3
      Re: vb 2005 email

      Hi Tony,

      See if the problem is addressed here:



      --

      Best regards,

      Carlos J. Quintero

      MZ-Tools: Productivity add-ins for Visual Studio
      You can code, design and document much faster:
      MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.



      "Tony Mastracchio" <TonyMast@MSN.C om> escribió en el mensaje news:uPL158yLGH A.3196@TK2MSFTN GP09.phx.gbl...
      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

      Comment

      Working...