I'm trying to open the local mail window using the javascript window.location.href=mailto:<addresses>
. However, my addresses exceed the maximum length. So I slice it into pieces, and send these one after the other, after a specific timeout. However, the second relocation will not open a new (Outlook) mail window if the first is still open... Is there any way to get around this? Or is there another/better way to open multiple mail windows on the local client?
Any help would be greatly appreciated!
The code:
function Send_Mails(mails) {
var timeout = 2000;
var maxUrlCharacters = 1900;
var currIndex = 0;
var nextIndex = 0;
if (mails.length < maxUrlCharacters) {
window.location = 'mailto:' + mails;
return;
}
do {
currIndex = nextIndex;
nextIndex = mails.indexOf(';', currIndex + 1);
} while (nextIndex != -1 && nextIndex < maxUrlCharacters)
if (currIndex == -1) {
window.location = 'mailto:' + mails;
} else {
window.location = 'mailto:' + mails.slice(0, currIndex);
setTimeout(function () {
Send_Mails(mails.slice(currIndex + 1));
}, timeout);
}
}
This opens the first mailwindow correctly, but the second one is never opened as long as the first one is open.
Best regards, Hans