Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Error while sending email [modified]

Error while sending email [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
sysadminhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vipul Mehta
    wrote on last edited by
    #1

    Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email

            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress("some email address...");
            mailMessage.To.Add(new MailAddress("some email address..."));
            mailMessage.IsBodyHtml = true;
            mailMessage.Subject = "Test Mail";
    
            mailMessage.Body = "Test Mail";
    
            // Instantiate a new instance of SmtpClient
            SmtpClient mSmtpClient = new SmtpClient();
    
            // Send the mail message
            mSmtpClient.Host = "SMTP IP Address";
            mSmtpClient.Send(mailMessage);
    

    Is this a network issue? Or do I need to provide the credentials as well?

    Regards, Vipul Mehta

    modified on Wednesday, November 12, 2008 10:17 AM

    D R 2 Replies Last reply
    0
    • V Vipul Mehta

      Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email

              MailMessage mailMessage = new MailMessage();
              mailMessage.From = new MailAddress("some email address...");
              mailMessage.To.Add(new MailAddress("some email address..."));
              mailMessage.IsBodyHtml = true;
              mailMessage.Subject = "Test Mail";
      
              mailMessage.Body = "Test Mail";
      
              // Instantiate a new instance of SmtpClient
              SmtpClient mSmtpClient = new SmtpClient();
      
              // Send the mail message
              mSmtpClient.Host = "SMTP IP Address";
              mSmtpClient.Send(mailMessage);
      

      Is this a network issue? Or do I need to provide the credentials as well?

      Regards, Vipul Mehta

      modified on Wednesday, November 12, 2008 10:17 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You may want to see if the SMTP server you're using demands you provide credentials to use it.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      • V Vipul Mehta

        Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("some email address...");
                mailMessage.To.Add(new MailAddress("some email address..."));
                mailMessage.IsBodyHtml = true;
                mailMessage.Subject = "Test Mail";
        
                mailMessage.Body = "Test Mail";
        
                // Instantiate a new instance of SmtpClient
                SmtpClient mSmtpClient = new SmtpClient();
        
                // Send the mail message
                mSmtpClient.Host = "SMTP IP Address";
                mSmtpClient.Send(mailMessage);
        

        Is this a network issue? Or do I need to provide the credentials as well?

        Regards, Vipul Mehta

        modified on Wednesday, November 12, 2008 10:17 AM

        R Offline
        R Offline
        Roger Wright
        wrote on last edited by
        #3

        Vipul Mehta wrote:

        Is this a network issue?

        It may be. Is the From address in the same domain as the SMTP server? A lot of installations set the SMTP server to refuse relaying foreign addresses, that is the server will not transport any email that didn't originate in its own domain. For instance, if I send an email from user@mydomain.com using the server smtp.yourdomain.com, if relaying is disabled on the server, my email will be rejected. This is to protect SMTP servers from being used to send spam, and is usually a good practice for most organizations.

        "A Journey of a Thousand Rest Stops Begins with a Single Movement"

        V 1 Reply Last reply
        0
        • R Roger Wright

          Vipul Mehta wrote:

          Is this a network issue?

          It may be. Is the From address in the same domain as the SMTP server? A lot of installations set the SMTP server to refuse relaying foreign addresses, that is the server will not transport any email that didn't originate in its own domain. For instance, if I send an email from user@mydomain.com using the server smtp.yourdomain.com, if relaying is disabled on the server, my email will be rejected. This is to protect SMTP servers from being used to send spam, and is usually a good practice for most organizations.

          "A Journey of a Thousand Rest Stops Begins with a Single Movement"

          V Offline
          V Offline
          Vipul Mehta
          wrote on last edited by
          #4

          OK I got a chance to talk to our network team & there was some blocking done from their side & they will make appropriate settings to nake this working. Thakns very much for all your prompt replies

          Regards, Vipul Mehta

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups