Reputation: 7315
I'm new to doing this sort of thing but I want to get the output from my application which sends mail. For example I want to be able to know if
I know how to send the mail using System.Net.Mail but is there any way to get this information ?
EDIT:
In the link David Stratton posted you can see the log and it receives the status codes like
Is there a way to get these events live so that as each one comes I can display them?
Upvotes: 1
Views: 1833
Reputation: 73564
If you want to create a log file based on the SMTP session, you can modify your .config file to do this automatically. Instructions here (archive.org backup). Same instructions can also be found at this SO answer.
Upvotes: 5
Reputation: 44605
I think that if at any point any of the 3 steps you mentioned would fail you would get an exception which you can catch with try/catch.
Critical point is probably the last one because once you queue the email in the SMTP server's queue you have no exceptions but it could still happen the email is not sent.
Upvotes: 1
Reputation:
Put your SmtpClient.Send()
call in a try/catch block and catch the below errors.
ArgumentNullException
InvalidOperationException
ObjectDisposedException
SmtpException
SmtpFailedRecipientsException
Reference: http://msdn.microsoft.com/en-us/library/swas0fwc.aspx
Upvotes: 6