Saturday, November 3, 2007

People and Groups bulk email issue

If you have more than 60 users in a sharepoint group, while trying to e-mail to all the users nothing happens. Unlike the normal lists, group views do not have the 'edit view' to edit the item limit.
When you click on 'Action-> email URL is formed like 'mail to: onemail; twomail;.......'
As you know, IE has a limitation to process 2048 characters. So if you select more than 60 users, it will get jammed.
If it is okay to change the item limit follow this:
  1. Go to the groups page(People.aspx)
  2. Settings -> list settings
  3. click on the desired view under the 'Views' section
  4. In the item limit area, limit the items you want to.

For any reason, if you do not wish to change the item limit follow this:
This procedure basically copies all the email ids to a clip board, that you can paste manually into the notes/outlook.

  1. Locate the 'People.aspx' page and open.
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS
  2. Locate the code block for the function 'function BtnEmailClick(viewId)' and replace with the following code.

    function BtnEmailClick(viewId)
    var emails = GetSelectedUsers(viewId, "email", ";");
    if (emails.length == 0)
    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), "");
    // Post the string to the clipboard if IE.
    if (ClipBoard(emails))
    alert( countNeedles(";", emails) + " email addresses have been copied to your clipboard.");
    return false;

    //Copying mails to the clipboard
    function ClipBoard(s)
    if (!document.all)
    return false;
    // This is for IE only
    var holdtext = document.getElementById('holdtext');
    holdtext.innerText = s;
    var Copied = holdtext.createTextRange();
    return true;

    //Counting the number of mail ids to confirm the user
    function countNeedles(needle, haystack)
    count = 1;
    pos = haystack.indexOf(needle);
    while ( pos != -1 )
    pos = haystack.indexOf(needle, pos+1);
    } return count;

  3. Any where in the page, paste the following line. In my case, I pasted after the 'ms-quicklaunchheader' DIV tag.
    <TEXTAREA ID="holdtext"></TEXTAREA>