I would like to know if there is a simple way to capture a transcript of the SMTP session when sending email using the System.Net.Mail.MailClient. In cases where an 开发者_如何转开发error is generated (ex: relaying denied) I would like to display the whole transcript to the user.
If there are previous questions that discuss this I was unable to find them. I am working with VB.NET, but C# examples are also appreciated. Thanks in advance for any suggestions!
Cheers, JE
I think you can get the actual transcript by turning on logging for system.net. Unfortunately I don't think this is real-time so its not an option for you. Instead you'll just have to try sending and catching the SmtpException and then inspecting the SmtpException.StatusCode.
If you're having another process send for you (such as IIS) and you're basically just dropping off messages for it to deliver then there's no real way to get some of these exceptions in real-time unfortunately.
There is an interesting SMTP-tester post here that I've never tried but sounds interesting. Can I test SmtpClient before calling client.Send()?
精彩评论