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. C#
  4. Error-While sending Mail

Error-While sending Mail

Scheduled Pinned Locked Moved C#
helpcsharpcom
9 Posts 4 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.
  • S Offline
    S Offline
    Satish Developer
    wrote on last edited by
    #1

    Hi, I designed a windows applciation by reading mail id's from text file and sending mails. But after sending more than 900 mails i am getting this error. Exception Occured System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host Can any one help reg this error... I used the code as follows MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } } G. Satish

    D S S 3 Replies Last reply
    0
    • S Satish Developer

      Hi, I designed a windows applciation by reading mail id's from text file and sending mails. But after sending more than 900 mails i am getting this error. Exception Occured System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host Can any one help reg this error... I used the code as follows MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } } G. Satish

      D Offline
      D Offline
      duncanmhor
      wrote on last edited by
      #2

      Satish - Developer wrote:

      after sending more than 900 mails

      This may be your problem. I rather imagine your ISP wwill have terminated the SMTP connection after you sending so many emails. You should check with them about their bulk email policy.

      "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

      S 1 Reply Last reply
      0
      • D duncanmhor

        Satish - Developer wrote:

        after sending more than 900 mails

        This may be your problem. I rather imagine your ISP wwill have terminated the SMTP connection after you sending so many emails. You should check with them about their bulk email policy.

        "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

        S Offline
        S Offline
        Satish Developer
        wrote on last edited by
        #3

        Can u explain reg this... where i have to check for this...

        D 1 Reply Last reply
        0
        • S Satish Developer

          Can u explain reg this... where i have to check for this...

          D Offline
          D Offline
          duncanmhor
          wrote on last edited by
          #4

          You'll need to check with whoever runs the SMTP server that you are using to send your email. Many ISPs have rules about the number of emails you can send at a time to prevent spamming. I assume you have the permission of the people you are emailing?

          "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

          S 1 Reply Last reply
          0
          • D duncanmhor

            You'll need to check with whoever runs the SMTP server that you are using to send your email. Many ISPs have rules about the number of emails you can send at a time to prevent spamming. I assume you have the permission of the people you are emailing?

            "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

            S Offline
            S Offline
            Satish Developer
            wrote on last edited by
            #5

            When i run the Email application, automatically the to-address is repeating. ie. TO: satish.g@techgene.com; kiran@techgene.com; madhu@techgene.com; the above line is for one mail. And for next mail TO: satish.g@techgene.com; kiran@techgene.com; madhu@techgene.com; suchi@techgene.com like this for mail to mail.. the toaddress is repeating. But when i debug this, there is no loops to get this, and also when sending mail there is only one id in to-address? any idea ? what's the reason by coming like this? there is no loop to come like this. u can see the code in above posting

            1 Reply Last reply
            0
            • S Satish Developer

              Hi, I designed a windows applciation by reading mail id's from text file and sending mails. But after sending more than 900 mails i am getting this error. Exception Occured System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host Can any one help reg this error... I used the code as follows MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } } G. Satish

              S Offline
              S Offline
              Sun Rays
              wrote on last edited by
              #6

              Satish - Developer wrote:

              objMailMessage.Body =

              Hi, in objMailMessage.To set only one ID. and all other ID set in objMailMessage.Cc Try it.

              Thanks, Sun Rays Rate this post if you like answer. My Articles

              S 1 Reply Last reply
              0
              • S Sun Rays

                Satish - Developer wrote:

                objMailMessage.Body =

                Hi, in objMailMessage.To set only one ID. and all other ID set in objMailMessage.Cc Try it.

                Thanks, Sun Rays Rate this post if you like answer. My Articles

                S Offline
                S Offline
                Satish Developer
                wrote on last edited by
                #7

                Hi, Please see the code below. I am reading mailid's from text file. In each line there is only one mailID. so "_mailid" contains only 1 id. now can u suggest how to put cc MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } }

                S 1 Reply Last reply
                0
                • S Satish Developer

                  Hi, Please see the code below. I am reading mailid's from text file. In each line there is only one mailID. so "_mailid" contains only 1 id. now can u suggest how to put cc MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } }

                  S Offline
                  S Offline
                  Sun Rays
                  wrote on last edited by
                  #8

                  Hi,

                  Satish - Developer wrote:

                  MailAddress SendFrom = new MailAddress(txtFromAddr.Text);

                  without doing this. Just create mailmessage object. MailMessage objMailMessage = new MailMessage(); objMailMessage.To = "toUser's email ID"; objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); objSmtpClient.Send(objMailMessage); Just try this. If you are getting error then u must have to chekc for smtp setting of server.

                  Thanks, Sun Rays Rate this post if you like answer. My Articles

                  1 Reply Last reply
                  0
                  • S Satish Developer

                    Hi, I designed a windows applciation by reading mail id's from text file and sending mails. But after sending more than 900 mails i am getting this error. Exception Occured System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host Can any one help reg this error... I used the code as follows MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.domain.com"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); while (!strdata.EndOfStream) { _mailId = Convert.ToString(strdata.ReadLine()); if (_mailId != "") { MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); } } G. Satish

                    S Offline
                    S Offline
                    Shpendh
                    wrote on last edited by
                    #9

                    is your PORT number correct...?

                    spaps

                    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