My SharePoint Blog

Blogs On SharePoint Technologies


Search Site


My SharePoint Blog recommends any of the following books...


Recent comments

Tags

None

    Categories


    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Workaround For SharePoint Group Email Limits

    By default when you click Actions --> E-Mail Users, you are limited by characters count in the mailto: property. If you have a large number of users in in a SharePoint Group and you want to email them the action will die without a message. I wrote a bit of Javascript to capture the emails (when the user clicks "E-Mail Users") and copy them to the clipboard if IE or display a div if FF. This way you can start your email client and paste all the addresses in appropriate field. Backup then Edit:

    C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/LAYOUTS/people.aspx



    Find (~line # 78):

    function BtnEmailClick(viewId){
        var emails = GetSelectedUsers(viewId, "email", ";");
        if (emails.length == 0)
        {
                alert(noUserEmailSelectedMsg);
                return false;
        }
        emails = "mailto:" + escapeProperly(emails);
        window.location = emails;
        return false;
    }

     

    Replace with:

    /*             POPUP Email Addresses to DIV or Clipboard.               */

    // OLD METHOD
    // function BtnEmailClick(viewId)
    // {
    // var emails = GetSelectedUsers(viewId, "email", ";");
    // if (emails.length == 0)
    // {
    // alert(noUserEmailSelectedMsg);
    // return false;
    // }
    // emails = "mailto:" + escapeProperly(emails);
    // window.location = emails;
    // return false;
    // }


    // NEW METHOD
    function BtnEmailClick(viewId)
    {
        var emails = GetSelectedUsers(viewId, "email", ";");
        if (emails.length == 0)
        {
            alert(noUserEmailSelectedMsg);
            return false;
        }
        emails = escapeProperly(emails);
        emails = unescape(emails);
        // get rid of the anchor mailto:
        emails = emails.replace(emails.substring(emails.indexOf('<'), emails.indexOf('>', emails.indexOf('<')) + 1), "");
        var regEx = /;/g;
        // alert(emails);
        // Post the string to the clipboard if IE.
        if (ClipBoard(emails))
        {
            alert( countNeedles(";", emails) + " email addresses have been copied to your clipboard.");
        } else { // Pop the email in a div.
            emails = emails.replace(regEx, ";\n");
            // make pretty for div
            document.getElementById('popEmailTextArea').innerHTML = unescape(emails);
            popup(document.getElementById('popEmailDiv'));
        }
        return false;
    }
    function popup( obj )
    {
        with( obj.style )
        {
            display = "inline"; position = "relative";
        }
    }
    function unpop( obj )
    {
        obj.style.display = "none";
    }
    function ClipBoard(s)
    {
        if (!document.all)
            return false;
        // IE only
        var holdtext = document.getElementById('holdtext');
        holdtext.innerText = s; Copied = holdtext.createTextRange();
        Copied.execCommand("Copy");
        return true;
    }
    function countNeedles(needle, haystack)
    {
        count = 1;
        pos = haystack.indexOf(needle);
        while ( pos != -1 )
        {
            count++;
            pos = haystack.indexOf(needle, pos+1);
        }
        return count;
    }
    /*       END: POPUP Email Addresses to DIV or Clipboard.        */

     


    Find this:

    <body>

    And paste below:

    <div id="popEmailDiv" style="margin: 10px; display: none">
        <p style="border: 1px solid red; margin: 3px; padding: 3px; color: red; background-color: pink; text-align: center">
            &nbsp;
            <span style="font-weight: bold; font-size: 16px; color: red">Copy and paste email addresses:</span>
        </p>
    </div>

     

     

    Save and test. Summary: Mailto links are limited to 2,083 characters in IE. SharePoint performs a redirect to a "mailto" link which would normally open your email client. If the length of the URL (mailto) is longer than this nothing happens and the redirect is ignored. You can read more about the IE limitation here: http://support.microsoft.com/default.aspx?scid=KB;en-us;q208427

     


    Categories: SharePoint
    Posted by Kevin on Tuesday, October 23, 2007 4:10 PM
    Permalink | Comments (2) | Post RSSRSS comment feed

    Comments