Can I test SmtpClient before calling client.Send()?

前端 未结 6 790
夕颜
夕颜 2020-11-28 10:58

This is related to a question I asked the other day on how to send email.

My new, related question is this... what if the user of my application is behind a firew

6条回答
  •  不知归路
    2020-11-28 11:57

    I think this is a case where exception handling would be the preferred solution. You really don't know that it will work until you try, and failure is an exception.

    Edit:

    You'll want to handle SmtpException. This has a StatusCode property, which is an enum that will tell you why the Send() failed.

提交回复
热议问题