OK, so who said this was going to be
Having initially sorted out the ‘Great Mailto Mystery‘ (thanks to some considerable patience on the part of my design partner Peter). But then they began to fail again – I’d hit the 2K limit.
As I said in my previous post there is a general limit on the length of urls in IE of 2083 characters and this, of course, applies to mailtos – a particular form of url.
My eTimesheet application provides a facility to email (or SMS) all the freelancers working in a particular period (usually a week but also during any search period). This list is created during the iteration through the array of bookings, so it contains duplicates where freelancers work for more than one client in that week. I had failed to clean up the list, instead relying (unconsciously) on the generosity of others i.e. mail servers are not as dumb as me and don’t send the same email twice when there are duplicates in the Bcc list.
Being self-taught in PHP (a little learning is certainly a dangerous thing!) I tend to learn this stuff as I go and in response to actual need. I had therefore managed to overlook the array_unique function (along with dozens of its friends). So, having built my (semi-colon separated) list of emails, I needed to de-duplicate:
$working_emails = explode(';',$working_emails);
$working_emails = array_unique($working_emails);
$working_emails = implode(';',$working_emails);
A shorter url, and all was well with the world – at least until someone wants to email everyone who worked last year …
Or there are more than about 80 people to email (I have average email length of around 24 characters but see this post for a higher figure).
I need a generic solution!
I’m not expecting to post regularly on this blog – for that you’ll need my twitter feed (#like_thats_gonna_happen). The intention is that I will post small things I discover – solutions to obscure problems, clever tricks I find etc – that will be useful to me and perhaps others. It will help me avoid that “reinventing the wheel” feeling and at least I’ll know where to find them!
Hope you find at least some of this useful.
I struggled with this problem for quite some time before coming to a “solution’. If my google trawl is anything to go by, so have a fair number of others.
Actually there isn’t a problem, as such, just a limitation of what you can do in certain browsers (you know who you are IE).
If you have a mailto link that is longer than 512 characters you will run into problems. The exciting bit (lol) is that they won’t be apparent if you test in FireFox, Safari, Chrome or Opera. But if you click on the link in IE (I’ve only tested 8 and 9 but I assume it’s the same with other versions) then you will see the problem – or rather you won’t as nothing much happens. The email client is not called, no email is created and you are sent to a blank page or alternatively absolutely nothing happens.
There may be the following error message: “The data area passed to a system call is too small.” This can be seen by double-clicking on the task bar.
The solution, of sorts, is either to shorten the mailto link (difficult in my case as it is dynamically generated) or try something else.
It seems that if you turn on Protected Mode in IE this can (partially) help. Turning on Protected Mode is done via the Tools menu – choose Internet Options and click on the Security tab. Bizzarely, this seems to turned off by default in some installations. This seems to fix the problem as this raises the limit to around
2K 2083 (see my new post here) which should be enough, but …
If this doesn’t solve the problem you may have exceeded the larger 2K character limit in IE.
More anon …