Posts

Showing posts from January, 2007

HOW TO send an email with a Word or Excel file attachment built on the fly

This question was asked on a Forum and the poster faced a situation where some hundred invoices had to be sent as an attachment to different receipients each pre-filled with user specific data retreived from the database. Creating these invoices manually, saving the files and picking them up programmatically to be emailed was the obvious time-consuming solution. It also carries the additional overhead of having to delete the files after emailing those attachments. I remembered reading that with System.Net.Mail, attachments could be created from a stream . Now there is also a cool re-usable method " DataTable2ExcelString " which can be used to generate an Excel sheet ( or Word document ) programmatically . I packed both of these ideas into a quick and dirty code snippet as a proof of concept. The email with the dynamically generated attachment can be copied to the sender's address also if proof of delivery or archiving is required. Related links: *  HOW TO impleme...

New in VS.NET 2005 - Development Settings

Working on the VS.NET 2005 IDE, if you noticed some feature from VS.NET 2003 missing or misplaced - be aware that VS.NET 2005 introduces customizable Development Settings . These templated Settings maybe choosen based on the predominant activity of the developer with the IDE and further customized. The new IDE setting changes can be saved in a .vssettings file. The advantage of having this kind of customizability is that over a period of time a best set of features which boost productivity can evolve and these can be shared across a team or with other developers. Scott Guthrie has a tip for folks with the C# Development Settings profile who do not get to see the document icon highlighted in the Solution Explorer while moving through files in the VS.NET code editor. This feature can be enabled by selecting Tools->Options | Projects and Solutions -> General and checking the "Track Active Item in Solution Explorer" checkbox.

HOW TO control the timing of window.onload event

The Javascript window.onload event fires AFTER all page content including any page elements like bulky images, have loaded. As the DOM is not fully loaded until then, any script written to achieve some UI effect on the page elements on page load may not have the desired impact. To correct this aberration, there are 2 good solutions. The solution by Peter-Paul Koch uses inline Javascript & CSS and the other by Dean Edwards uses conditional compilation (available through HTML & JScript in IE) and the defer attribute (a HTML 4.0 property available in IE) of the SCRIPT tag.