There are some things that are unreasonably difficult even in this day of age. Well, not exactly difficult. Let’s say programmer unfriendly. For instance, opening a new mail window in your default mail client from windows .NET application. Preferably with address filled in. Google for it and you will get the same answer I did. Just start a process with “mailto:email@address.xyz” command. Sounds simple enough. Right?

 

Well, not exactly. What nobody tells you is what running a process with “mailto:” command actually does. No, it doesn’t start your default mail client with parameter “mailto:”. Instead, it launches Internet Explorer, searches what application was set there as default mail client, then runs that one with parameter “mailto:”. Now, I don’t know about you, but I don’t like going through a proxy to achieve my goal. Well, I ignored my intuition and dispatched this functionality with first public beta to some co-workers in my department. Well, it did work on my PC after all. What could possibly go wrong?

And then, all hell broke loose. A co-worker of mine kindly reminded me that this mail feature doesn’t work. Instead it opened gazillion Internet Explorer windows dynamically. Shutting down my app didn’t help. It seemed as though Internet Explorer got into a vicious cycle and opened new window every half a second. The only thing that helped was forced log off. Now, you see, we use Lotus Notes as our default mail client (sure, some use Outlook, but they are in vast minority). I use latest and greatest version of course. Most people, however, don’t. They use 8.5.3 version and apparently this version has some issues with IE10 and IE11 and “mailto:” calls (also noted here). Basically, what this means is that starting process with “mailto:” as command will end catastrophically. Seeing as upgrade to 9.0.1 is not planned for some time and IE10 is now in-house standard, I had to find another solution. Preferably something that would open e-mail clients eithout the help of Internet Explorer.

In this situation, there are two things you can do. You can ignore officially unsupported warning and use MAPI and live with consequences or you can call notes.exe with “mailto:email@address.xyz” as parameter. I chose the later. But, as always, there was a catch. The application must still work for those 3 Outlook clients. So, what I basically did was this:

  1. Application checks the registry for key HKEY_CURRENT_USER\Software\Clients\mail. This key contains default mail client set by user. If key is not set (which is exactly the case with Lotus Notes 8.5.3), application makes an assumption that you are using Lotus Notes client. However, if key is set, application just uses whatever value it contains.
  2. If your default mail client is Outlook, application just starts process with “mailto:” command. And it is done. No harm there. To be honest, it could have used outlook.exe command line as well.
  3. If your default mail client is Lotus Notes, however, the application checks the registry for DLLPath value of key HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\value_found_in_step_one (value is either “Lotus Notes” for old clients or “IBM Notes” for new ones). This key value always exists and will tell you a location where this particular mail client is installed.
  4. Then, application just starts new process with “notes.exe” in found location as command and “mailto:” as parameter.

 

This works on all currently supported Lotus Notes clients and doesn’t include IE. Fixpack was promptly released and issue was gone. Hopefully for good.