I was working on fixing the exception reporting. And working. And working… Every little alley took another twist and turn.
First I had to figure out how EurekaLog was calling up your email program. Two complaints about it was more than I wanted to hear:
Your debug routine fails to send the file, as it tries to start windows mail for some reason known to it’s self rather than using the default mail client (in my case thunderbird)
I tried to fill up the exception report but gave up when it asked for this server, that server! I then got really annoyed because it launched Outlook - I never, ever use it or want to use it.
So I found out that it was using Messaging Application Programming Interface (or MAPI). The problem is MAPI is not included with every email program, and will in such situations bring up a different program than the one you have as default. I also checked out the INDY (a Delphi package that provides Web services), and it has the same problem.
But there was a solution. The “mailto” command you find on websites brings up your default email program. It also has parameters that allow you to specify who it is going to, the subject, the body of the message and others. On a windows machine, that same function can be called by passing the mailto line to ShellExecute.
I thought I’d try it. It didn’t take too much to get a test going. And I was quite pleased to see that the web limitation of 256 characters was not there.
I had to figure out how to disconnected EurekaLog’s report and set up my own Exception Dialog form. Then I had to figure out how to pull all the info out of EurekaLog’s debug information for inclusion into my form. That went fairly smoothly until I got to the Operating System information. That was only in their log file, so I had to work out how to parse their log to find that information.
Wonderful. It was all set up and ready to go. I saw EurekaLog was attaching its log as a zip file. Hmmm. I don’t need to do that, since all the relevant error information was now in the body of the email message. But wouldn’t it be great if I could also (at the user’s option) automatically attach the GEDCOM and/or the Behold file and the future Log file?
Then I discovered (and this took over a day to realize it) that mailto did not support attachments with most email programs. I found a lot of people asking how to do this via Google searches, and there were several answers given. I tried them all and they didn’t work for me. Then I found that it only worked for certain email program such as Outlook, so that was no good.
But I was rolling. I knew there must be a some simple way to get the attachments to the email program. I posted a question on StackOverflow: How can a Delphi Program send an Email with Attachments via the DEFAULT E-mail Client?. The answers were coming in, but they were all telling me to go MAPI or INDY.
So I continued to do some research and I discovered some code that was not too complicated on Dragging and Dropping files from my application to Windows Explorer. Doing so would also allow me to list the files and allow the user to (relatively) easily drag them over to the email message that I’d create for them. It’s not the perfect solution, but it seemed like the best I could do if I wanted to ensure I properly accessed the user’s default email program.
I set up a Filelistbox on my Exception form, and got it all working. It was old code and required a few changes to work with Unicode strings. But it worked.
Next was setting up the Filelistbox to list the GEDCOM files and … oh oh. It required all the files be in the same directory because it was designed for an explorer-like directory listing. That didn’t work. After some thinking, I copied my ElTree from Behold’s FindFiles window and adapted that.
Once I had the file list box, then I discovered the GetFileListDataObject routine from the code I adapted also assumed everything was in the same directory. I had to convert that to figure out the data objects of each file no matter what directory they were in. This was code that I really didn’t understand. But I took a shot at it. I was extremely surprised when this worked the very first time - a rare event for me and for programmers in general.
I had to add “Select All” and “Select None” buttons to easily allow you to pick the files to drag. The selection of individual files had an interaction with the dragging, so that was a glitch that is still outstanding as I write this.
Then the cruncher came. My final tests and I get an exception while doing the mailto. It turns out that there is a limitation of 2048 characters that I can pass via mailto. Could I live with that? I don’t know. I was hoping to append the log file once I recreate it next version to the exception email, but that would now not be possible.
I was just about ready to take my lumps and maybe even back out of this whole thing, when surprise of surprises - another answer on my StackOverflow question appeared.
Instead of using “mailto”, mjustin pointed me to a way to used the Windows “sendto” command to send the attached files to the default email program and set up a new message with the files attached. This method will not require the user to do the extra step and drag and drop the files to the message and apparently it also has no limit in size of message either.
So just a bit more work to implement this now.
Yes. I did get carried away. This was a lot of work for something not part of the core functionality of Behold. But I’m not one to let something go half way. Best to finish it off while its in the moment.
And how was your holiday weekend?