Friday, December 14, 2012

Send Email to Disk

Sometimes you need to check email sending locally and since you cannot send it over the network so there is a way to send your emails to you hard drive.

I am going to provide the Web.config settings which have been required to send email to local disk. Below are the setting which you can copy and paste in  Web.config:

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory"
from="sender@mailserver.com">
<specifiedPickupDirectory pickupDirectoryLocation="C:\EmailFolder" />
</smtp>
</mailSettings>
</system.net>
</configuration>

This will create .eml Emails files to the specified folder (here, C:\EmailFolder), which
must already exist. If you double-click .eml email files in Windows Explorer,
they’ll open in Outlook Express or Windows Mail.

Hope this will help.


Thursday, December 13, 2012

SQL: Setting Value to Column with NULL values

Here is the structure of how to update a table column which has NULL values in it.

UPDATE TableName SET ColumnName = NewValue where ColumnName Is Null

Now lets apply it against a real scenario.

update Student set IsAdded = 0 where IsAdded Is Null

After executing this query all the values for the column IsAdded gets to 0 where it has NULL values.

Hope you have got the idea.


SQL: Set Default Value for a Column

Below is the structure for setting the default value for a column.  You will not face NULL values in the columns where this constraint gets added.

ALTER TABLE TableName
ADD CONSTRAINT
ADDED DEFAULT DefaultValue FOR ColumnName

Now lets apply it with a table so you will get more idea of how to work with it.


ALTER TABLE Student
ADD CONSTRAINT
ADDED DEFAULT 0 FOR IsAdded

Hope you have got the idea.