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}, [email protected], {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 lives in Berea, Ohio. The principal member of Inedo, LLC, he uses his 10 years of IT experience to bring custom software solutions to small- and mid-sized businesses and to help other software development organizations utilize best practices in their products. On the Internet, Alex can usually be found answering questions in various newsgroups and posting some rather interesting real-life examples of how not to program on his Web site TheDailyWTF.com. You can contact Alex directly via email at [email protected].,

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events