How to check if the mail has been sent successfully

前端 未结 8 1430
夕颜
夕颜 2020-12-24 07:00

I am developing an Asp.Net application, where I am sending a mail to the user\'s email address, if he forgets the password.

I want to check if the mail has been sent

8条回答
  •  醉话见心
    2020-12-24 07:26

    Put the .Send(msg) method in a try catch block, and catch SmtpFailedRecipientException.

    try
    {
        mail.Send(msg);
    }
    catch (SmtpFailedRecipientException ex)
    {
        // ex.FailedRecipient and ex.GetBaseException() should give you enough info.
    }
    

提交回复
热议问题