Send simple EMail

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

    Send simple EMail

    VS 2005 - XP media - VB .net - winforms - .net 2.0



    Just trying to send an email, here is the code and the error message that I
    get. I can't figure out how to fix it?





    'create the mail message

    Dim mail As New MailMessage()

    Dim smtp As New SmtpClient("htt p://mail.Someplace. com")

    Dim WhatTimeIsIt As DateTime

    mail.From = New MailAddress("To ny@Someplace.co m")

    mail.To.Add("To nyMast@Someplac e.com")

    WhatTimeIsIt = DateTime.Now

    mail.Subject = "This is an email" & Format(WhatTime IsIt) & " - "
    & " winforms"

    mail.Body = "this is a sample body"

    'This next line didn't help error but i was getting error prior to putting
    this line in.

    smtp.Credential s = New Net.NetworkCred ential("Usernam e", "Secrete")

    smtp.Send(mail)





    -----------------Error Message -----------------------



    System.Net.Mail .SmtpException was unhandled

    Message="Failur e sending mail."

    Source="System"

    StackTrace:

    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)

    at WinformsEMailte st.Form1.Button 1_Click(Object sender, EventArgs e)
    in C:\AllUserFiles \Movies\Winform sEMailtest\Winf ormsEMailtest\F orm1.vb:line
    28

    at System.Windows. Forms.Control.O nClick(EventArg s e)

    at System.Windows. Forms.Button.On Click(EventArgs e)

    at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)

    at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
    button, Int32 clicks)

    at System.Windows. Forms.Control.W ndProc(Message& m)

    at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)

    at System.Windows. Forms.Button.Wn dProc(Message& m)

    at
    System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)

    at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&
    m)

    at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)

    at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
    msg)

    at
    System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
    dwComponentID, Int32 reason, Int32 pvLoopData)

    at
    System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
    reason, ApplicationCont ext context)

    at
    System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32 reason,
    ApplicationCont ext context)

    at System.Windows. Forms.Applicati on.Run(Applicat ionContext context)

    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.OnRun ()

    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.DoApp licationModel()

    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.Run(S tring[]
    commandLine)

    at WinformsEMailte st.My.MyApplica tion.Main(Strin g[] Args) in
    17d14f5c-a337-4978-8281-53493378c1071.v b:line 81

    at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
    args)

    at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
    assemblySecurit y, String[] args)

    at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()

    at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)

    at System.Threadin g.ExecutionCont ext.Run(Executi onContext
    executionContex t, ContextCallback callback, Object state)

    at System.Threadin g.ThreadHelper. ThreadStart()

    ------------------------------------------------------------------------------------------------------------------------------------------------------


  • Tom

    #2
    Re: Send simple EMail

    You don't need HTTP:// in front of the SMTP server, it isn't http, so
    you dont need it :)

    Tony M wrote:
    VS 2005 - XP media - VB .net - winforms - .net 2.0
    >
    >
    >
    Just trying to send an email, here is the code and the error message that I
    get. I can't figure out how to fix it?
    >
    >
    >
    >
    >
    'create the mail message
    >
    Dim mail As New MailMessage()
    >
    Dim smtp As New SmtpClient("htt p://mail.Someplace. com")
    >
    Dim WhatTimeIsIt As DateTime
    >
    mail.From = New MailAddress("To ny@Someplace.co m")
    >
    mail.To.Add("To nyMast@Someplac e.com")
    >
    WhatTimeIsIt = DateTime.Now
    >
    mail.Subject = "This is an email" & Format(WhatTime IsIt) & " - "
    & " winforms"
    >
    mail.Body = "this is a sample body"
    >
    'This next line didn't help error but i was getting error prior to putting
    this line in.
    >
    smtp.Credential s = New Net.NetworkCred ential("Usernam e", "Secrete")
    >
    smtp.Send(mail)
    >
    >
    >
    >
    >
    -----------------Error Message -----------------------
    >
    >
    >
    System.Net.Mail .SmtpException was unhandled
    >
    Message="Failur e sending mail."
    >
    Source="System"
    >
    StackTrace:
    >
    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
    >
    at WinformsEMailte st.Form1.Button 1_Click(Object sender, EventArgs e)
    in C:\AllUserFiles \Movies\Winform sEMailtest\Winf ormsEMailtest\F orm1.vb:line
    28
    >
    at System.Windows. Forms.Control.O nClick(EventArg s e)
    >
    at System.Windows. Forms.Button.On Click(EventArgs e)
    >
    at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
    >
    at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
    button, Int32 clicks)
    >
    at System.Windows. Forms.Control.W ndProc(Message& m)
    >
    at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
    >
    at System.Windows. Forms.Button.Wn dProc(Message& m)
    >
    at
    System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
    >
    at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&
    m)
    >
    at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)
    >
    at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
    msg)
    >
    at
    System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
    dwComponentID, Int32 reason, Int32 pvLoopData)
    >
    at
    System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
    reason, ApplicationCont ext context)
    >
    at
    System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32 reason,
    ApplicationCont ext context)
    >
    at System.Windows. Forms.Applicati on.Run(Applicat ionContext context)
    >
    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.OnRun ()
    >
    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.DoApp licationModel()
    >
    at
    Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.Run(S tring[]
    commandLine)
    >
    at WinformsEMailte st.My.MyApplica tion.Main(Strin g[] Args) in
    17d14f5c-a337-4978-8281-53493378c1071.v b:line 81
    >
    at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
    args)
    >
    at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
    assemblySecurit y, String[] args)
    >
    at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
    >
    at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
    >
    at System.Threadin g.ExecutionCont ext.Run(Executi onContext
    executionContex t, ContextCallback callback, Object state)
    >
    at System.Threadin g.ThreadHelper. ThreadStart()
    >
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    >
    >

    Comment

    • rowe_newsgroups

      #3
      Re: Send simple EMail

      On Jun 15, 11:46 pm, "Tony M" <TonyMast_NOS.. .@msn.comwrote:
      VS 2005 - XP media - VB .net - winforms - .net 2.0
      >
      Just trying to send an email, here is the code and the error message that I
      get. I can't figure out how to fix it?
      >
      'create the mail message
      >
      Dim mail As New MailMessage()
      >
      Dim smtp As New SmtpClient("htt p://mail.Someplace. com")
      >
      Dim WhatTimeIsIt As DateTime
      >
      mail.From = New MailAddress("T. ..@Someplace.co m")
      >
      mail.To.Add("To nyM...@Someplac e.com")
      >
      WhatTimeIsIt = DateTime.Now
      >
      mail.Subject = "This is an email" & Format(WhatTime IsIt) & " - "
      & " winforms"
      >
      mail.Body = "this is a sample body"
      >
      'This next line didn't help error but i was getting error prior to putting
      this line in.
      >
      smtp.Credential s = New Net.NetworkCred ential("Usernam e", "Secrete")
      >
      smtp.Send(mail)
      >
      -----------------Error Message -----------------------
      >
      System.Net.Mail .SmtpException was unhandled
      >
      Message="Failur e sending mail."
      >
      Source="System"
      >
      StackTrace:
      >
      at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
      >
      at WinformsEMailte st.Form1.Button 1_Click(Object sender, EventArgs e)
      in C:\AllUserFiles \Movies\Winform sEMailtest\Winf ormsEMailtest\F orm1.vb:line
      28
      >
      at System.Windows. Forms.Control.O nClick(EventArg s e)
      >
      at System.Windows. Forms.Button.On Click(EventArgs e)
      >
      at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
      >
      at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
      button, Int32 clicks)
      >
      at System.Windows. Forms.Control.W ndProc(Message& m)
      >
      at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
      >
      at System.Windows. Forms.Button.Wn dProc(Message& m)
      >
      at
      System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
      >
      at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&
      m)
      >
      at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
      Int32 msg, IntPtr wparam, IntPtr lparam)
      >
      at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
      msg)
      >
      at
      System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
      dwComponentID, Int32 reason, Int32 pvLoopData)
      >
      at
      System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
      reason, ApplicationCont ext context)
      >
      at
      System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32 reason,
      ApplicationCont ext context)
      >
      at System.Windows. Forms.Applicati on.Run(Applicat ionContext context)
      >
      at
      Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.OnRun ()
      >
      at
      Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.DoApp licationModel()
      >
      at
      Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.Run(S tring[]
      commandLine)
      >
      at WinformsEMailte st.My.MyApplica tion.Main(Strin g[] Args) in
      17d14f5c-a337-4978-8281-53493378c1071.v b:line 81
      >
      at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
      args)
      >
      at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
      assemblySecurit y, String[] args)
      >
      at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
      >
      at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
      >
      at System.Threadin g.ExecutionCont ext.Run(Executi onContext
      executionContex t, ContextCallback callback, Object state)
      >
      at System.Threadin g.ThreadHelper. ThreadStart()
      >
      ------------------------------------------------------------------------------------------------------------------------------------------------------
      Also, Mcafee and other virus protection programs prevent
      System.Net.Mail and System.Web.Mail from sending emails - it picks
      them up as a mass mailing worm and generates the "Failure sending
      mail" message. Be sure to add them to the list of allowed programs if
      you think it will be a problem.

      Thanks,

      Seth Rowe

      Comment

      • Tony M

        #4
        Re: Send simple EMail


        Ok, I kind of got it to work thanks to you guys.
        I can send some emails successfully to 2 servers only (or websites).
        Everything else gives me the error listed below and I know they are good
        addresses.
        I also used bounce@altohiwa y.com and same error (which is a place to test
        email).
        If I go to outlook (same computer same time) I can send to all these email
        addresses without error.

        "Mailbox unavailable. The server response was: <bounce@altohiw ay.comNo
        such user here"}
        System.Net.Mail .SmtpFailedReci pientException'

        Thanks again in advance


        "Tony M" <TonyMast_NOSPA M@msn.comwrote in message
        news:eJkCgj8rHH A.2368@TK2MSFTN GP05.phx.gbl...
        VS 2005 - XP media - VB .net - winforms - .net 2.0
        >
        >
        >
        Just trying to send an email, here is the code and the error message that
        I get. I can't figure out how to fix it?
        >
        >
        >
        >
        >
        'create the mail message
        >
        Dim mail As New MailMessage()
        >
        Dim smtp As New SmtpClient("htt p://mail.Someplace. com")
        >
        Dim WhatTimeIsIt As DateTime
        >
        mail.From = New MailAddress("To ny@Someplace.co m")
        >
        mail.To.Add("To nyMast@Someplac e.com")
        >
        WhatTimeIsIt = DateTime.Now
        >
        mail.Subject = "This is an email" & Format(WhatTime IsIt) & " - "
        & " winforms"
        >
        mail.Body = "this is a sample body"
        >
        'This next line didn't help error but i was getting error prior to putting
        this line in.
        >
        smtp.Credential s = New Net.NetworkCred ential("Usernam e", "Secrete")
        >
        smtp.Send(mail)
        >
        >
        >
        >
        >
        -----------------Error Message -----------------------
        >
        >
        >
        System.Net.Mail .SmtpException was unhandled
        >
        Message="Failur e sending mail."
        >
        Source="System"
        >
        StackTrace:
        >
        at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
        >
        at WinformsEMailte st.Form1.Button 1_Click(Object sender, EventArgs e)
        in
        C:\AllUserFiles \Movies\Winform sEMailtest\Winf ormsEMailtest\F orm1.vb:line
        28
        >
        at System.Windows. Forms.Control.O nClick(EventArg s e)
        >
        at System.Windows. Forms.Button.On Click(EventArgs e)
        >
        at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
        >
        at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
        button, Int32 clicks)
        >
        at System.Windows. Forms.Control.W ndProc(Message& m)
        >
        at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
        >
        at System.Windows. Forms.Button.Wn dProc(Message& m)
        >
        at
        System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
        >
        at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&
        m)
        >
        at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
        Int32 msg, IntPtr wparam, IntPtr lparam)
        >
        at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
        msg)
        >
        at
        System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
        dwComponentID, Int32 reason, Int32 pvLoopData)
        >
        at
        System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
        reason, ApplicationCont ext context)
        >
        at
        System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
        reason, ApplicationCont ext context)
        >
        at System.Windows. Forms.Applicati on.Run(Applicat ionContext context)
        >
        at
        Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.OnRun ()
        >
        at
        Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.DoApp licationModel()
        >
        at
        Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.Run(S tring[]
        commandLine)
        >
        at WinformsEMailte st.My.MyApplica tion.Main(Strin g[] Args) in
        17d14f5c-a337-4978-8281-53493378c1071.v b:line 81
        >
        at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
        args)
        >
        at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
        assemblySecurit y, String[] args)
        >
        at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
        >
        at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
        >
        at System.Threadin g.ExecutionCont ext.Run(Executi onContext
        executionContex t, ContextCallback callback, Object state)
        >
        at System.Threadin g.ThreadHelper. ThreadStart()
        >
        ------------------------------------------------------------------------------------------------------------------------------------------------------
        >
        >

        Comment

        • Tony M

          #5
          Re: Send simple EMail

          Nevermind I figured it out.
          Incorrect credentials!
          Works fin now thanks again


          "Tony M" <TonyMast_NOSPA M@msn.comwrote in message
          news:eJkCgj8rHH A.2368@TK2MSFTN GP05.phx.gbl...
          VS 2005 - XP media - VB .net - winforms - .net 2.0
          >
          >
          >
          Just trying to send an email, here is the code and the error message that
          I get. I can't figure out how to fix it?
          >
          >
          >
          >
          >
          'create the mail message
          >
          Dim mail As New MailMessage()
          >
          Dim smtp As New SmtpClient("htt p://mail.Someplace. com")
          >
          Dim WhatTimeIsIt As DateTime
          >
          mail.From = New MailAddress("To ny@Someplace.co m")
          >
          mail.To.Add("To nyMast@Someplac e.com")
          >
          WhatTimeIsIt = DateTime.Now
          >
          mail.Subject = "This is an email" & Format(WhatTime IsIt) & " - "
          & " winforms"
          >
          mail.Body = "this is a sample body"
          >
          'This next line didn't help error but i was getting error prior to putting
          this line in.
          >
          smtp.Credential s = New Net.NetworkCred ential("Usernam e", "Secrete")
          >
          smtp.Send(mail)
          >
          >
          >
          >
          >
          -----------------Error Message -----------------------
          >
          >
          >
          System.Net.Mail .SmtpException was unhandled
          >
          Message="Failur e sending mail."
          >
          Source="System"
          >
          StackTrace:
          >
          at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
          >
          at WinformsEMailte st.Form1.Button 1_Click(Object sender, EventArgs e)
          in
          C:\AllUserFiles \Movies\Winform sEMailtest\Winf ormsEMailtest\F orm1.vb:line
          28
          >
          at System.Windows. Forms.Control.O nClick(EventArg s e)
          >
          at System.Windows. Forms.Button.On Click(EventArgs e)
          >
          at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
          >
          at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
          button, Int32 clicks)
          >
          at System.Windows. Forms.Control.W ndProc(Message& m)
          >
          at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
          >
          at System.Windows. Forms.Button.Wn dProc(Message& m)
          >
          at
          System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
          >
          at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&
          m)
          >
          at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
          Int32 msg, IntPtr wparam, IntPtr lparam)
          >
          at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
          msg)
          >
          at
          System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
          dwComponentID, Int32 reason, Int32 pvLoopData)
          >
          at
          System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
          reason, ApplicationCont ext context)
          >
          at
          System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
          reason, ApplicationCont ext context)
          >
          at System.Windows. Forms.Applicati on.Run(Applicat ionContext context)
          >
          at
          Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.OnRun ()
          >
          at
          Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.DoApp licationModel()
          >
          at
          Microsoft.Visua lBasic.Applicat ionServices.Win dowsFormsApplic ationBase.Run(S tring[]
          commandLine)
          >
          at WinformsEMailte st.My.MyApplica tion.Main(Strin g[] Args) in
          17d14f5c-a337-4978-8281-53493378c1071.v b:line 81
          >
          at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
          args)
          >
          at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
          assemblySecurit y, String[] args)
          >
          at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
          >
          at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
          >
          at System.Threadin g.ExecutionCont ext.Run(Executi onContext
          executionContex t, ContextCallback callback, Object state)
          >
          at System.Threadin g.ThreadHelper. ThreadStart()
          >
          ------------------------------------------------------------------------------------------------------------------------------------------------------
          >
          >

          Comment

          Working...