While it is not difficult to send email via C#, there tends to be a lot of code that I put in place every time. For starts I like to have a class or at least one method that all email in the application go through. The main reason is so that I can quickly see where the method is called and see where emails are sent. This also aids in debugging, and understanding of code when someone comes onto the project.
One of the first things asked is, how do I turn off emails during development. This provides one location that can be commented out. I take it one step further and make it web.config setting. When email is disabled, I still would like to see a log that it would have been sent. So, I have a log file that the email is written to instead of actually sending the email. The log is only used for development purposes.
I also like to have default email to/from incase the unexpected case of no to/from is encounter when I am not expecting it to. This way I am notified. I also pull the smtp server from the web.config instead of hard coding it. You may also notice I call something I call Config instead of accessing the web.config directly. This is because, I again like to have all access my app settings in one class that can be easily changed if needed. For example, in certain instances configuration may need to be stored in a database instead of the config file. This makes that change very easy to make just by changing and testing one class.
Below is the method / code snippet I use: