Sep 17, 2015

Printing all properties of an Object

To write all the properties and such of an object to the console (or log or to front end), use TypeDescriptor class.

foreach(System.ComponentModel.PropertyDescriptor descriptor in System.ComponentModel.TypeDescriptor.GetProperties(obj))
{
    string name=descriptor.Name;
    object value=descriptor.GetValue(obj);
    Console.WriteLine("{0}={1}",name,value);
}

Where obj is the class for which properties are to be printed.

Sep 15, 2015

Creating a custom class in C# for creating a log file

Code for the class to create log file:

Local SMTP server for Testing and Development on Windows

Use Papercut.

Download the application and run it. It will set up an SMTP server when it's running. Configure your application to use 'localhost' (or the machine where the server is running) as the SMTP server. If you need to use a non-default port number, you can configure it in Options.

As per the CodePlex webpage:
Papercut is a simplified SMTP server designed to only receive messages (not to send them on) with a GUI on top of it allowing you to see the messages it receives. It doesn't enforce any restrictions on addresses, it just takes the message and allows you see it. It is only active while it is running, and if you want it in the background, just minimize it to the system tray. When it receives a new message, a balloon message will show up to let you know.