Monday, 23 December 2013

Send email in C#/.net

Next part of the bit in my project is to send out an email containing the check-list generated to current logged-in user. Below is the method i called to email out the generated check list. message body can be customized according to your requirement. You can also define the contact but in my project, the requirement is to generate checklist and email it to myself/current user.

(PS: Please note that i have changed the original names i used in the project, that's why it indicate red under checkbox names.)







How to find your SMTP server?

You can simply find it from your outlook. 
1. File-> Info
2. Account Settings -> Account Settings



3. In the Email tab double click on Name
















4. "Server" shows you the SMTP server that you need to refer for the SMTP client.

(MS outlook 2010)






Friday, 20 December 2013

Read from Active Directory/AD Groups using C# (.NET Framework 3.5 or newer)

Below is the method I used to search a name from the AD. In my code user can enter the name they want to search in AD and bring the results to a drop down list.


 Search name can also be the first name, last name, username or full name. Therefore this can be changed as one of below;

 




A name can be searched in AD Groups. I have used the domain user name (SamAccountName) to identify a name in AD group which is unique and more accurate. Since I had to bring up search results as user's full name (Display name) ":" domain user name format, I then had to filter out the domain user name into a string variable as below. (Get the names after ":" character).


 To search in AD groups FindByIdentity has been used as below;