Problem clearing send error in email program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ed Bitzer

    Problem clearing send error in email program

    Trying to send groups of email with program using System.Net.Mail . I
    do not clear MailMessage but repeatedly loop changing only the Bcc
    entries. Works fine if all addresses are valid. As a simple test I
    have attempted to send a valid address, then an invalid address which
    my ISP (Comcast) will reject immediately as "Not our customer". I
    catch the exception, display and then continue looping to send several
    additional valid. The balance all are "caught" and display the an
    error but they are sent. I have negligible knowledge of exceptions
    but suspect I need to clear.

    loop through the following changing only the bcc
    try
    smtpobject.Send (MyMailMsg)
    Catch ex as Exception
    msgbox(ex.tostr ing)
    end try

    Appreciate as usual,

    Ed


  • Steve Gerrard

    #2
    Re: Problem clearing send error in email program

    Ed Bitzer wrote:
    Trying to send groups of email with program using System.Net.Mail . I
    do not clear MailMessage but repeatedly loop changing only the Bcc
    entries. Works fine if all addresses are valid. As a simple test I
    have attempted to send a valid address, then an invalid address which
    my ISP (Comcast) will reject immediately as "Not our customer". I
    catch the exception, display and then continue looping to send several
    additional valid. The balance all are "caught" and display the an
    error but they are sent. I have negligible knowledge of exceptions
    but suspect I need to clear.
    >
    loop through the following changing only the bcc
    try
    smtpobject.Send (MyMailMsg)
    Catch ex as Exception
    msgbox(ex.tostr ing)
    end try
    >
    Appreciate as usual,
    >
    Ed
    It looks to me like you need to reset MyMailMsg if there is an exception. The
    exception will not persist past the end of the try block.


    Comment

    • Cor Ligthert[MVP]

      #3
      Re: Problem clearing send error in email program

      Ed,

      Can you show the full loop, because in my idea can this not be the base of
      your problem.

      Cor

      Comment

      • Rad [Visual C# MVP]

        #4
        Re: Problem clearing send error in email program

        On Mon, 18 Feb 2008 21:53:33 -0500, Ed Bitzer wrote:
        Trying to send groups of email with program using System.Net.Mail . I
        do not clear MailMessage but repeatedly loop changing only the Bcc
        entries. Works fine if all addresses are valid. As a simple test I
        have attempted to send a valid address, then an invalid address which
        my ISP (Comcast) will reject immediately as "Not our customer". I
        catch the exception, display and then continue looping to send several
        additional valid. The balance all are "caught" and display the an
        error but they are sent. I have negligible knowledge of exceptions
        but suspect I need to clear.
        >
        loop through the following changing only the bcc
        try
        smtpobject.Send (MyMailMsg)
        Catch ex as Exception
        msgbox(ex.tostr ing)
        end try
        >
        Appreciate as usual,
        >
        Ed
        Ed,

        Post a copy of the entire loop. There are ways you can structure the loop
        and the error handler to be more robust to exceptions
        --

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Problem clearing send error in email program

          "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
          >Trying to send groups of email with program using System.Net.Mail . I do
          >not clear MailMessage but repeatedly loop changing only the Bcc entries.
          >Works fine if all addresses are valid. As a simple test I have attempted
          >to send a valid address, then an invalid address which my ISP (Comcast)
          >will reject immediately as "Not our customer". I catch the exception,
          >display and then continue looping to send several additional valid. The
          >balance all are "caught" and display the an error but they are sent. I
          >have negligible knowledge of exceptions but suspect I need to clear.
          >>
          >loop through the following changing only the bcc
          >try
          > smtpobject.Send (MyMailMsg)
          >
          >Catch ex as Exception
          > msgbox(ex.tostr ing)
          ex = null
          or
          ex = nothing 'don't know about that one for sure
          No, that doesn't make sense. 'Try...Catch' as used in the OP's sample is
          OK.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

          Comment

          • Mr. Arnold

            #6
            Re: Problem clearing send error in email program


            "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
            news:O3FUoVwcIH A.4436@TK2MSFTN GP05.phx.gbl...
            "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
            >>Trying to send groups of email with program using System.Net.Mail . I do
            >>not clear MailMessage but repeatedly loop changing only the Bcc entries.
            >>Works fine if all addresses are valid. As a simple test I have
            >>attempted to send a valid address, then an invalid address which my ISP
            >>(Comcast) will reject immediately as "Not our customer". I catch the
            >>exception, display and then continue looping to send several additional
            >>valid. The balance all are "caught" and display the an error but they
            >>are sent. I have negligible knowledge of exceptions but suspect I need
            >>to clear.
            >>>
            >>loop through the following changing only the bcc
            >>try
            >> smtpobject.Send (MyMailMsg)
            >>
            >>Catch ex as Exception
            >> msgbox(ex.tostr ing)
            > ex = null
            > or
            > ex = nothing 'don't know about that one for sure
            >
            No, that doesn't make sense. 'Try...Catch' as used in the OP's sample is
            OK.
            >
            I disagree with you, because I have used both methods to clear the Exception
            to keep an application running when it would have stopped on the try/catch
            while it was in a processing loop, particularly when processing many methods
            within the processing loop and method calling other methods and all of them
            having Try/Catches to prevent it from blowing up on the try/catch above it.

            This method was used to look for a particular Exception in a multiple
            Exceptions try/catch, and if I got the Exception to report the Exception to
            a log, clear the Exception and let the processing flow back to the top of
            the loop and continue process, otherwise, throw the Exception in each
            method above it until it got to the top Try/Catch and terminate the
            application.

            I have used the method in C# and VB.Net solution with the try/catch and in
            VB.Net with the Error GoTo.

            Comment

            • Ed Bitzer

              #7
              Re: Problem clearing send error in email program

              deleted a bit to the thread to shorten, comment at bottom
              >>>Catch ex as Exception
              >>> msgbox(ex.tostr ing)
              >> ex = null
              >> or
              >> ex = nothing 'don't know about that one for sure
              >>
              >No, that doesn't make sense. 'Try...Catch' as used in the OP's
              >sample is OK.
              >>
              >
              I disagree with you, because I have used both methods to clear the
              Exception to keep an application running when it would have stopped
              on the try/catch while it was in a processing loop, particularly
              when processing many methods within the processing loop and method
              calling other methods and all of them having Try/Catches to prevent
              it from blowing up on the try/catch above it.
              >
              This method was used to look for a particular Exception in a
              multiple Exceptions try/catch, and if I got the Exception to report
              the Exception to a log, clear the Exception and let the processing
              flow back to the top of the loop and continue process, otherwise,
              throw the Exception in each method above it until it got to the top
              Try/Catch and terminate the application.
              >
              I have used the method in C# and VB.Net solution with the try/catch
              and in VB.Net with the Error GoTo.
              I tried and ex = null constant is no longer supported
              ex= nothing ok but error repeated even for valid messages which were
              sent.

              I have included more extensive code as requested - appreciate your
              taking a look.

              Ed

              \


              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Problem clearing send error in email program

                "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                >>>Trying to send groups of email with program using System.Net.Mail . I do
                >>>not clear MailMessage but repeatedly loop changing only the Bcc
                >>>entries. Works fine if all addresses are valid. As a simple test I
                >>>have attempted to send a valid address, then an invalid address which
                >>>my ISP (Comcast) will reject immediately as "Not our customer". I catch
                >>>the exception, display and then continue looping to send several
                >>>additional valid. The balance all are "caught" and display the an error
                >>>but they are sent. I have negligible knowledge of exceptions but
                >>>suspect I need to clear.
                >>>>
                >>>loop through the following changing only the bcc
                >>>try
                >>> smtpobject.Send (MyMailMsg)
                >>>
                >>>Catch ex as Exception
                >>> msgbox(ex.tostr ing)
                >> ex = null
                >> or
                >> ex = nothing 'don't know about that one for sure
                >>
                >No, that doesn't make sense. 'Try...Catch' as used in the OP's sample is
                >OK.
                >
                I disagree with you, because I have used both methods to clear the
                Exception to keep an application running when it would have stopped on the
                try/catch while it was in a processing loop
                If you are catching the exception inside the loop it won't stop the loop.
                Setting the exception variable to 'Nothing' doesn't have any influence if
                you are using 'Catch ex As <exception type>'.
                This method was used to look for a particular Exception in a multiple
                Exceptions try/catch, and if I got the Exception to report the Exception
                to a log, clear the Exception
                You do not have to "clear" exceptions. They are not bubbled up if they are
                caught and not rethrown.

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                Comment

                • Mr. Arnold

                  #9
                  Re: Problem clearing send error in email program


                  "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
                  news:eUmUD4zcIH A.5164@TK2MSFTN GP03.phx.gbl...
                  "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                  >>>>Trying to send groups of email with program using System.Net.Mail . I
                  >>>>do not clear MailMessage but repeatedly loop changing only the Bcc
                  >>>>entries. Works fine if all addresses are valid. As a simple test I
                  >>>>have attempted to send a valid address, then an invalid address which
                  >>>>my ISP (Comcast) will reject immediately as "Not our customer". I
                  >>>>catch the exception, display and then continue looping to send several
                  >>>>additiona l valid. The balance all are "caught" and display the an
                  >>>>error but they are sent. I have negligible knowledge of exceptions
                  >>>>but suspect I need to clear.
                  >>>>>
                  >>>>loop through the following changing only the bcc
                  >>>>try
                  >>>> smtpobject.Send (MyMailMsg)
                  >>>>
                  >>>>Catch ex as Exception
                  >>>> msgbox(ex.tostr ing)
                  >>> ex = null
                  >>> or
                  >>> ex = nothing 'don't know about that one for sure
                  >>>
                  >>No, that doesn't make sense. 'Try...Catch' as used in the OP's sample
                  >>is OK.
                  >>
                  >I disagree with you, because I have used both methods to clear the
                  >Exception to keep an application running when it would have stopped on
                  >the try/catch while it was in a processing loop
                  >
                  If you are catching the exception inside the loop it won't stop the loop.
                  Setting the exception variable to 'Nothing' doesn't have any influence if
                  you are using 'Catch ex As <exception type>'.
                  >
                  >This method was used to look for a particular Exception in a multiple
                  >Exceptions try/catch, and if I got the Exception to report the Exception
                  >to a log, clear the Exception
                  >
                  You do not have to "clear" exceptions. They are not bubbled up if they
                  are caught and not rethrown.
                  >
                  Look man, you can't tell me something that I have done myself. This is
                  totally ridiculous, particularly when I have done it.


                  Comment

                  • Herfried K. Wagner [MVP]

                    #10
                    Re: Problem clearing send error in email program

                    "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                    >>>>>Trying to send groups of email with program using System.Net.Mail . I
                    >>>>>do not clear MailMessage but repeatedly loop changing only the Bcc
                    >>>>>entries. Works fine if all addresses are valid. As a simple test I
                    >>>>>have attempted to send a valid address, then an invalid address which
                    >>>>>my ISP (Comcast) will reject immediately as "Not our customer". I
                    >>>>>catch the exception, display and then continue looping to send
                    >>>>>several additional valid. The balance all are "caught" and display
                    >>>>>the an error but they are sent. I have negligible knowledge of
                    >>>>>exceptio ns but suspect I need to clear.
                    >>>>>>
                    >>>>>loop through the following changing only the bcc
                    >>>>>try
                    >>>>> smtpobject.Send (MyMailMsg)
                    >>>>>
                    >>>>>Catch ex as Exception
                    >>>>> msgbox(ex.tostr ing)
                    >>>> ex = null
                    >>>> or
                    >>>> ex = nothing 'don't know about that one for sure
                    >>>>
                    >>>No, that doesn't make sense. 'Try...Catch' as used in the OP's sample
                    >>>is OK.
                    >>>
                    >>I disagree with you, because I have used both methods to clear the
                    >>Exception to keep an application running when it would have stopped on
                    >>the try/catch while it was in a processing loop
                    >>
                    >If you are catching the exception inside the loop it won't stop the loop.
                    >Setting the exception variable to 'Nothing' doesn't have any influence if
                    >you are using 'Catch ex As <exception type>'.
                    >>
                    >>This method was used to look for a particular Exception in a multiple
                    >>Exceptions try/catch, and if I got the Exception to report the Exception
                    >>to a log, clear the Exception
                    >>
                    >You do not have to "clear" exceptions. They are not bubbled up if they
                    >are caught and not rethrown.
                    >
                    Look man, you can't tell me something that I have done myself. This is
                    totally ridiculous, particularly when I have done it.
                    Well, just show me where the behavior you describe is specified and/or show
                    me a code sample that is a proof of what you are saying.

                    --
                    M S Herfried K. Wagner
                    M V P <URL:http://dotnet.mvps.org/>
                    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                    Comment

                    • Mr. Arnold

                      #11
                      Re: Problem clearing send error in email program


                      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
                      news:uLzPuJ1cIH A.4436@TK2MSFTN GP05.phx.gbl...
                      "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                      >>>>>>Trying to send groups of email with program using System.Net.Mail . I
                      >>>>>>do not clear MailMessage but repeatedly loop changing only the Bcc
                      >>>>>>entries . Works fine if all addresses are valid. As a simple test I
                      >>>>>>have attempted to send a valid address, then an invalid address
                      >>>>>>which my ISP (Comcast) will reject immediately as "Not our
                      >>>>>>customer" . I catch the exception, display and then continue looping
                      >>>>>>to send several additional valid. The balance all are "caught" and
                      >>>>>>display the an error but they are sent. I have negligible knowledge
                      >>>>>>of exceptions but suspect I need to clear.
                      >>>>>>>
                      >>>>>>loop through the following changing only the bcc
                      >>>>>>try
                      >>>>>> smtpobject.Send (MyMailMsg)
                      >>>>>>
                      >>>>>>Catch ex as Exception
                      >>>>>> msgbox(ex.tostr ing)
                      >>>>> ex = null
                      >>>>> or
                      >>>>> ex = nothing 'don't know about that one for sure
                      >>>>>
                      >>>>No, that doesn't make sense. 'Try...Catch' as used in the OP's sample
                      >>>>is OK.
                      >>>>
                      >>>I disagree with you, because I have used both methods to clear the
                      >>>Exception to keep an application running when it would have stopped on
                      >>>the try/catch while it was in a processing loop
                      >>>
                      >>If you are catching the exception inside the loop it won't stop the
                      >>loop. Setting the exception variable to 'Nothing' doesn't have any
                      >>influence if you are using 'Catch ex As <exception type>'.
                      >>>
                      >>>This method was used to look for a particular Exception in a multiple
                      >>>Exceptions try/catch, and if I got the Exception to report the
                      >>>Exception to a log, clear the Exception
                      >>>
                      >>You do not have to "clear" exceptions. They are not bubbled up if they
                      >>are caught and not rethrown.
                      >>
                      >Look man, you can't tell me something that I have done myself. This is
                      >totally ridiculous, particularly when I have done it.
                      >
                      Well, just show me where the behavior you describe is specified and/or
                      show me a code sample that is a proof of what you are saying.
                      Sorry man, it's not my job. I got enough to do on the job. And just because
                      you say that something cannot happen doesn't make it so. One can think
                      outside the box and apply something. I have done it on more than a few
                      occasions to think outside the box have someone comeback and tell that they
                      didn't know that could be done, which I have been doing programming wise
                      since 1980. :)

                      :)

                      Comment

                      • Herfried K. Wagner [MVP]

                        #12
                        Re: Problem clearing send error in email program

                        "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                        >>>>>>>Trying to send groups of email with program using System.Net.Mail .
                        >>>>>>>I do not clear MailMessage but repeatedly loop changing only the
                        >>>>>>>Bcc entries. Works fine if all addresses are valid. As a simple
                        >>>>>>>test I have attempted to send a valid address, then an invalid
                        >>>>>>>addres s which my ISP (Comcast) will reject immediately as "Not our
                        >>>>>>>customer ". I catch the exception, display and then continue looping
                        >>>>>>>to send several additional valid. The balance all are "caught" and
                        >>>>>>>displa y the an error but they are sent. I have negligible
                        >>>>>>>knowledg e of exceptions but suspect I need to clear.
                        >>>>>>>>
                        >>>>>>>loop through the following changing only the bcc
                        >>>>>>>try
                        >>>>>>> smtpobject.Send (MyMailMsg)
                        >>>>>>>
                        >>>>>>>Catch ex as Exception
                        >>>>>>> msgbox(ex.tostr ing)
                        >>>>>> ex = null
                        >>>>>> or
                        >>>>>> ex = nothing 'don't know about that one for sure
                        >>>>>>
                        >>>>>No, that doesn't make sense. 'Try...Catch' as used in the OP's
                        >>>>>sample is OK.
                        >>>>>
                        >>>>I disagree with you, because I have used both methods to clear the
                        >>>>Exception to keep an application running when it would have stopped on
                        >>>>the try/catch while it was in a processing loop
                        >>>>
                        >>>If you are catching the exception inside the loop it won't stop the
                        >>>loop. Setting the exception variable to 'Nothing' doesn't have any
                        >>>influence if you are using 'Catch ex As <exception type>'.
                        >>>>
                        >>>>This method was used to look for a particular Exception in a multiple
                        >>>>Exception s try/catch, and if I got the Exception to report the
                        >>>>Exception to a log, clear the Exception
                        >>>>
                        >>>You do not have to "clear" exceptions. They are not bubbled up if they
                        >>>are caught and not rethrown.
                        >>>
                        >>Look man, you can't tell me something that I have done myself. This is
                        >>totally ridiculous, particularly when I have done it.
                        >>
                        >Well, just show me where the behavior you describe is specified and/or
                        >show me a code sample that is a proof of what you are saying.
                        >
                        Sorry man, it's not my job. I got enough to do on the job. And just
                        because you say that something cannot happen doesn't make it so. One can
                        think outside the box and apply something. I have done it on more than a
                        few occasions to think outside the box have someone comeback and tell that
                        they didn't know that could be done, which I have been doing programming
                        wise since 1980. :)
                        Well, that's nothing more than a proof that you are older than me, but it's
                        not a proof that you are right.

                        I am really wondering what you want to archieve by setting the variable 'ex'
                        to 'Nothing' if the exception is already caught and not rethrown. This
                        won't prevent it from bubbling up because it doesn't bubble up in this case
                        at all.

                        --
                        M S Herfried K. Wagner
                        M V P <URL:http://dotnet.mvps.org/>
                        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                        Comment

                        • Ed Bitzer

                          #13
                          Re: Problem clearing send error in email program


                          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
                          news:u$gqMg1cIH A.5984@TK2MSFTN GP06.phx.gbl...
                          "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                          >>>>>>>>Tryin g to send groups of email with program using
                          >>>>>>>>System. Net.Mail. I do not clear MailMessage but repeatedly
                          >>>>>>>>loop changing only the Bcc entries. Works fine if all
                          >>>>>>>>address es are valid. As a simple test I have attempted to
                          >>>>>>>>send a valid address, then an invalid address which my ISP
                          >>>>>>>>(Comcas t) will reject immediately as "Not our customer". I
                          >>>>>>>>catch the exception, display and then continue looping to
                          >>>>>>>>send several additional valid. The balance all are "caught"
                          >>>>>>>>and display the an error but they are sent. I have
                          >>>>>>>>negligi ble knowledge of exceptions but suspect I need to
                          >>>>>>>>clear .
                          >>>>>>>>>
                          >>>>>>>>loop through the following changing only the bcc
                          >>>>>>>>try
                          >>>>>>>> smtpobject.Send (MyMailMsg)
                          >>>>>>>>
                          >>>>>>>>Catch ex as Exception
                          >>>>>>>> msgbox(ex.tostr ing)
                          >>>>>>> ex = null
                          >>>>>>> or
                          >>>>>>> ex = nothing 'don't know about that one for sure
                          >>>>>>>
                          >>>>>>No, that doesn't make sense. 'Try...Catch' as used in the
                          >>>>>>OP's sample is OK.
                          >>>>>>
                          >>>>>I disagree with you, because I have used both methods to clear
                          >>>>>the Exception to keep an application running when it would have
                          >>>>>stopped on the try/catch while it was in a processing loop
                          >>>>>
                          >>>>If you are catching the exception inside the loop it won't stop
                          >>>>the loop. Setting the exception variable to 'Nothing' doesn't
                          >>>>have any influence if you are using 'Catch ex As <exception
                          >>>>type>'.
                          >>>>>
                          >>>>>This method was used to look for a particular Exception in a
                          >>>>>multiple Exceptions try/catch, and if I got the Exception to
                          >>>>>report the Exception to a log, clear the Exception
                          >>>>>
                          >>>>You do not have to "clear" exceptions. They are not bubbled up
                          >>>>if they are caught and not rethrown.
                          >>>>
                          >>>Look man, you can't tell me something that I have done myself.
                          >>>This is totally ridiculous, particularly when I have done it.
                          >>>
                          >>Well, just show me where the behavior you describe is specified
                          >>and/or show me a code sample that is a proof of what you are
                          >>saying.
                          >>
                          >Sorry man, it's not my job. I got enough to do on the job. And just
                          >because you say that something cannot happen doesn't make it so.
                          >One can think outside the box and apply something. I have done it
                          >on more than a few occasions to think outside the box have someone
                          >comeback and tell that they didn't know that could be done, which I
                          >have been doing programming wise since 1980. :)
                          >
                          Well, that's nothing more than a proof that you are older than me,
                          but it's not a proof that you are right.
                          >
                          I am really wondering what you want to archieve by setting the
                          variable 'ex' to 'Nothing' if the exception is already caught and
                          not rethrown. This won't prevent it from bubbling up because it
                          doesn't bubble up in this case at all.
                          >
                          --
                          M S Herfried K. Wagner
                          M V P <URL:http://dotnet.mvps.org/>
                          V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
                          I have been testing this afternoon with the loop described and shown
                          here again with the additional line setting the return value to ""
                          Try
                          smtpError = false
                          smtpObj.Send(My MailMsg)
                          Catch ex as Exception
                          returnValue = ex.GetBaseExcep tion.toString()
                          msgBox(returnva lue,,"Returned Server Response")
                          smtpError = true
                          logBatchArray(b atchNum) = returnValue
                          returnValue = ""
                          End Try

                          I have carefully stepped through the code and monitored the MyMailMsg
                          structure as I attempted to send a valid address, then a invalid and
                          then another valid and the addresses have appeared in MyMailMsg.bcc
                          when I check just after the line SmtpObj.Send(My MailMsg) yet the third
                          address, definitely a valid address, activates the Catch. So setting
                          returnValue = "" has not solved my problem.

                          Ed


                          Comment

                          • Mr. Arnold

                            #14
                            Re: Problem clearing send error in email program


                            "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
                            news:u$gqMg1cIH A.5984@TK2MSFTN GP06.phx.gbl...
                            "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb:
                            >>>>>>>>Tryin g to send groups of email with program using System.Net.Mail .
                            >>>>>>>>I do not clear MailMessage but repeatedly loop changing only the
                            >>>>>>>>Bcc entries. Works fine if all addresses are valid. As a simple
                            >>>>>>>>test I have attempted to send a valid address, then an invalid
                            >>>>>>>>addre ss which my ISP (Comcast) will reject immediately as "Not our
                            >>>>>>>>custome r". I catch the exception, display and then continue
                            >>>>>>>>loopi ng to send several additional valid. The balance all are
                            >>>>>>>>"caught " and display the an error but they are sent. I have
                            >>>>>>>>negligi ble knowledge of exceptions but suspect I need to clear.
                            >>>>>>>>>
                            >>>>>>>>loop through the following changing only the bcc
                            >>>>>>>>try
                            >>>>>>>> smtpobject.Send (MyMailMsg)
                            >>>>>>>>
                            >>>>>>>>Catch ex as Exception
                            >>>>>>>> msgbox(ex.tostr ing)
                            >>>>>>> ex = null
                            >>>>>>> or
                            >>>>>>> ex = nothing 'don't know about that one for sure
                            >>>>>>>
                            >>>>>>No, that doesn't make sense. 'Try...Catch' as used in the OP's
                            >>>>>>sample is OK.
                            >>>>>>
                            >>>>>I disagree with you, because I have used both methods to clear the
                            >>>>>Exceptio n to keep an application running when it would have stopped
                            >>>>>on the try/catch while it was in a processing loop
                            >>>>>
                            >>>>If you are catching the exception inside the loop it won't stop the
                            >>>>loop. Setting the exception variable to 'Nothing' doesn't have any
                            >>>>influence if you are using 'Catch ex As <exception type>'.
                            >>>>>
                            >>>>>This method was used to look for a particular Exception in a multiple
                            >>>>>Exceptio ns try/catch, and if I got the Exception to report the
                            >>>>>Exceptio n to a log, clear the Exception
                            >>>>>
                            >>>>You do not have to "clear" exceptions. They are not bubbled up if
                            >>>>they are caught and not rethrown.
                            >>>>
                            >>>Look man, you can't tell me something that I have done myself. This is
                            >>>totally ridiculous, particularly when I have done it.
                            >>>
                            >>Well, just show me where the behavior you describe is specified and/or
                            >>show me a code sample that is a proof of what you are saying.
                            >>
                            >Sorry man, it's not my job. I got enough to do on the job. And just
                            >because you say that something cannot happen doesn't make it so. One can
                            >think outside the box and apply something. I have done it on more than a
                            >few occasions to think outside the box have someone comeback and tell
                            >that they didn't know that could be done, which I have been doing
                            >programming wise since 1980. :)
                            >
                            Well, that's nothing more than a proof that you are older than me, but
                            it's not a proof that you are right.
                            >
                            I am really wondering what you want to archieve by setting the variable
                            'ex' to 'Nothing' if the exception is already caught and not rethrown.
                            This won't prevent it from bubbling up because it doesn't bubble up in
                            this case at all.
                            >
                            Yes, I remember now. I was throwing the Exception all the way back to the
                            top to the try/catch that was in the loop.
                            Then I looked at it with catches in the try, and if it was that one I wanted
                            to ignore, I just cleared the Exception and didn't throw it and just let the
                            program stay in the loop. Otherwise, the other catch was caught, and I throw
                            it there to make it come back to the top try/catch to log the message and
                            stop the program.

                            Yes, I caught it where it happened to log a message, and then I would throw
                            the Exception and brought it all the way back to the top, to look at it. It
                            was a long time ago back in 2005 when I did it to let the Windows service
                            application to continue processing or make the service stop.




                            Comment

                            • Ed Bitzer

                              #15
                              Re: Problem clearing send error in email program - an apology

                              I apologize to the group. The original problem was failure to clear
                              an array and while I thought I was sending one address at a time I was
                              progressively adding to MailMessage's bcc array/structure (actually
                              called something else which escapes me). Therefore only the first
                              batch was clean, the second failed logically but actaully was sending
                              a good and a bad, and the third failed even though a good address
                              becuase the bcc array now inclued two good and one bad. However to
                              further confuse me I kept changing my code attempting to create new
                              object to insure "cleanlines s" and tried setting my
                              System.Net.Mail .SmtpClient to nothing. When that did not work I got
                              caught up in the suggestion to introduce the ex = nothing code and my
                              testing proved nothing because I left a line clearing the
                              System.Net.Mail .Smtp Client elsewhere. I just found the mistake, the
                              loop is working fine and I further tested, with or without the line of
                              ex = nothing (in my case returnValue = "") and it is not needed.

                              I really had panicked after spending so many hours building this
                              program for the community and all of a sudden finding what appeared to
                              be an unsolvable flaw.

                              Ed



                              Comment

                              Working...