开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜