For quite a few months now, I’ve been struggling with an interesting and altogether too frustrating problem at work.
One of the things I hope to do as I move forward is be able to replace all my old intranet pages with new, shiny intranet pages. Using things like responsive design, fly-out menus, and rotating images on our site would go a long, long way toward bringing us into the 21st century.
When my predecessor in this job started the intranet site, he chose to use technology which was already considered out of date. I don’t know why he made that decision, but whatever the case, he left here with a lot of bad practices soundly in place.
This probably resulted from the confluence of being in a hurry and being self-taught as a programmer. You do what you know how to do and get it done as quickly as you can. Because you’re the one maintaining it, it’s only your mess you have to maintain, right?
One of the problems I’ve had to address is having data access code on each and every page accessing data. This was a bad practice, even when the technology he chose to implement was current. There were far better ways to do it, but he didn’t use them.
Another, however, wasn’t entirely his fault. Since our company chose to use Lotus Notes for their email system, anything we email around internally or externally is going through that system, period.
Working with LN in the technology he chose is a bit easier than in the current technology. The Computer Object Model (COM) applications of days past all had similar ways to communicate with each other and made for somewhat easy, if not messy, code for interoperability.
But with the new technology, the code is managed code, so the COM classes have to be “wrapped” in other code packages so they can talk to each other. It’s not a *huge* problem, but it does slow things down and makes it a little clumsy to write code to interoperate. But it’s a necessary requirement for us; we have a returns management portion of our intranet site, and it uses automated emails to send notifications around to both internal and external customers.
But I’ve never been able to get it working in the new technology. Never. No matter what I tried, my beloved new languages just couldn’t get things going through the system via email. Very, very frustrating, because some of the most critical portions of the intranet site can’t be upgraded until that hurdle is overcome. The system MUST be able to send emails, and now, it must send them with attachments.
Ah, the joy.
After working on this for…what? two years now?…I finally found the solution.
I wish I could take credit for it, but I can’t. I can take credit for never giving up, but it was the grace of our Lord and Savior Christ Jesus and His guiding hand on me which finally, after literal years of searching, led me to the answer I needed.
Which, of course, was multiple answers, not one.
Last month, I found a way to send an email through the system from a simple console application. (That’s a computer program without a user interface; it just uses what used to be known as the “DOS window”, if that helps.) It would send fine, but I needed it to send a LOT of text, and I need that text to be formatted with line breaks.
It’s that second part which was the biggest hurdle. Once I found a working piece of code to send mail through the system, I needed a way to make it attach the text, with potentially thousands of characters, and multiple line breaks, in the email and send it.
Today, I found that solution. It’s been there for a while, but maybe I didn’t see it before. All I could do until today was append the text, and it would take a lot of text, to be sure. But it couldn’t recognize the line breaks, at all. This nifty clue showed me how I could remove the (blank) body of the email altogether, create a rich text version of it, and add it back to the document as the body. This enabled the text to be seen as formatted with line breaks.
Voila! Email ready!
Now I can apply this to my web pages and see if it works, but first, I have to find a way to include attachments.
That’s tomorrow’s adventure in Google searching, I guess. 🙂
How’s it by you?