DevDisasters

OldMail Method

After three long interviews for a .NET developer position, Maxim received a fairly generous offer and accepted it on the spot. "Now, I don't mean to scare you off," Maxim's soon-to-be boss told him. "But the fella you're replacing was good. I mean, really good. He could code his way out of anything, and I just don't want you feeling overwhelmed when you come in and people are expecting the world from you."

Maxim was a little anxious, but he felt comfortable standing on the shoulders of giants. After all, it was a great opportunity for him to learn how his predecessor did things.

When his first day on the job finally came, Maxim loaded up the "Developer Workstation" instructions and proceeded to follow the steps needed to get the company's flagship application running on his computer.


As he made his way through the document, there was one step that completely threw him off: "To make sure that e-mails can be sent, install ClickYes, which can be found on the T: drive."

Problematic Execution
Maxim had no idea why such a dependency existed for sending e-mail, so he dug into the CommonUtils class and navigated to the SendEmail() function. What he found horrified and amazed him.

With the change log and source control history, Maxim was able to reconstruct the trials and tribulations his predecessor, "the .NET whiz," must have gone through to finally master programmatic e-mail.

2004-12-02 13:29 Check in code that does the following: Programmatically execute outlook.exe and wait five seconds for it to load up. With the outlook process in the foreground, send the following keystroke combination to outlook: {ctrl+n}, theUser@theDoma.com, {tab}, {tab}, Some Subject Line, {tab}, The Message Body, {ctrl+enter}. Close the outlook process.

2004-12-02 14:07 Deploy to the server and learn that it doesn't work so well. Go back to the drawing board.

2004-12-03 11:18 Check-in a custom e-mail class that wraps around the CDONTS [Collaboration Data Objects for Windows NT Server] library.

2004-12-03 12:39 Deploy to the server and learn that, because it's Windows 2003, it doesn't have CDONTS installed. Go back to the drawing board.

2004-12-06 13:36 Check-in another custom e-mail class that interops the Microsoft Outlook automation objects.

2004-12-06 13:51 Deploy to the server and learn that Outlook has an anti-hijacking feature that requires the user to click "Yes" to send an e-mail. Learn that, as a Web app, the Web user isn't presented with a dialog window that pops up on the server.

2004-12-07 07:18 Check-in an attempt to automatically click yes.

2004-12-07 09:03 Check-in another attempt to automatically click yes.

2004-12-07 10:28 Check-in yet another attempt to automatically click yes.

2004-12-07 16:22 Install, on the server, a newly purchased program called ClickYes that automatically clicks "Yes" to those dialogs.

NewMail Method
Instead of going through the trouble to install ClickYes on his workstation, Maxim decided to make one more revision to the SendEmail method.

2009-08-10 11:31 Replace entire method body with a call to SmtpClient.SendMessage in System.Web.Mail.

After that, Maxim was no longer worried about being dwarfed by the .NET whiz.


About the Author

Alex Papadimoulis is a managing partner at Inedo LLC and publisher of the Web site "Worse Than Failure" (WorseThanFailure.com). He writes the DevDisasters page in every issue of Redmond Developer News.

Reader Comments:

Wed, Oct 14, 2009 lovin_it

just love how management glorifies ex-programmers who 'seem' to do the job, but in light of this story, all they do are patch work that are stupid hacks. then to only put the burden on the next programmer and expect them to do a 'super' job of the previous programmer ... but we know is the silly hack.... no not all prev programmers are hacks, just the few that similar to glorified managers who talk the talk, but are just obnoxious cash cows. ah. the beauty of encapsulation and delegation.... hehem.

Fri, Oct 9, 2009 Matt Fritz Long Island, NY

Good observation on the dates. Still (as an ‘older guy’) I suspect there were better ways to send email from server apps in the bad ‘ol days of NT – even if it meant using a 3rd party tool. I seem to remember using MAPI in such instances though having to install Outlook on a server and be logged in as the user defined in Outlook’s mail profile was pretty lame. It looks like the ‘ol timer was just trying to ‘get it done’ with whatever hammer he could find.

Sun, Oct 4, 2009 Colin Perth

Ok - not the best way for the original developer, but if the "young" guy looked at the dates he would have realised why as in Dec 2004 the "old guy" was still using the 1.1 framework [at best] which had issues of its own with emails. Plus if this young stud completed his homework he would have seen the deprecation errors and moved to the 2.0 "System.Net.Mail" namespace (not the System.Web.Mail) - just goes to prove the shoe is not fitting just yet ;)

Thu, Oct 1, 2009

Ha..ha..ha.. reminds me of a "senior" guy I know who rewrote some of the built in methods in .NET because he didn't trust anything "that came out of the box".

Thu, Oct 1, 2009 Joshua Ramirez Twin Cities, MN

Classic...

Wed, Sep 30, 2009 Dave

Yes, don't we all just love snide little posts about older programmers!

Add Your Comment:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above