September 11, 2009

Send Email Using a DNS Server

An easy way to send mail from .NET is to use the DnsMailClient class. Here’s some sample code in both C# and VB: // in C#MailMessage msg = new MailMessage();msg.From = “[email protected]”;msg.To = “[email protected];[email protected]”;msg.Subject = “dns sending”;msg.Body = “it is a test.”;DnsMailClient client = new DnsMailClient();client.Send(msg);’ in VB.NETDim msg As

Preserve Browser Scroll Position After a Postback

For large web pages, you often want to maintain the user’s current scroll position after a postback. To do that, use one of the following methods: In Web.config, in the section, add the Boolean attribute maintainScrollPositionOnPostBack=”true”. This will maintain the scroll positions for all the web site pages. In the

Adding Workdays to a Date

This example adds the days of the week and the weeks separately. You never iterate over the loop more then four times regardless of the number of days being added. After adding the day of the week, simply add seven days for every five business days to calculate the final

How to Save URL Contents to an MHTML Archive Format

When you save an HTML file with Internet Explorer, it saves the contents as a Multipurpose Internet Mail Extension HTML (MHTML) file, with an .mht extension. But you can easily accomplish the same result programmatically, using the CDO Message object. Here’s an example: /// &ltsummary&gt/// Saves the url to a

Avoiding the Perils of C++0x Data Races

ace conditions are an inherent part of parallel programming. A race condition exists any time a program’s behavior may depend on the relative ordering of events on separate threads. In the vast majority of cases, race conditions are harmless?the program works regardless of which thread gets a lock first, or