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
- A connection has been established
- If the user was authenticated successfully
- If the mail was sent succesffully etc.
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
- 220 w2k Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Sat, 31 Dec 2005
- 250-w2k Hello
- 250-AUTH GSSAPI NTLM LOGIN..
- 250-AUTH=LOGIN..
- 250-TURN..
- 250-ATRN..
- 250-SIZE 2097152..
- 250-ETRN..
- 250-PIPELINING..
- 250-DSN..
- 250-ENHANCEDSTATUSCODES..
- 250-8bitmime..
- 250-BINARYMIME..
- 250-CHUNKING..
- 250-VRFY..
- 250 OK..
- MAIL FROM:..
- 250 2.1.0 [email protected] OK..
- RCPT TO:..
- 550 5.7.1 Unable to relay for [email protected]
Is there a way to get these events live so that as each one comes I can display them?
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