catch ex.innerexception in the smtpclass vb.net2008
am trying to catch the inner exception for the smtpclass with this code below, but it give another error saying the innerexception is not defined
Try
    mail.To.Add(lstRecipients(i))
    Try
        开发者_运维知识库SetStatus("Sending:-" & lstRecipients(i))
        smtp.Send(mail)
        lSent += 1
        bwrkMain.ReportProgress(i + 1)
        SetStatus("Sent:-" & lstRecipients(i))
        lSent += 1
    Catch ex As SmtpFailedRecipientsException
        bwrkMain.ReportProgress(i + 1)
        SetStatus("Error:-" & lstRecipients(i) & " - " &
            ex.InnerException.Message)
    End Try
Catch ex As Exception
    SetStatus("Error:-" & lstRecipients(i) & " - " & ex.Message)
End Try
The InnerException is not defined, have a look at the Exceptions within Exceptions section
Make sure to check that your InnerException is not Nothing before trying to use it:
If Not(ex.InnerException Is Nothing) Then
     SetStatus("Error:-" & lstRecipients(i) & " - " &
            ex.InnerException.Message)
End If
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论