0

I am trying to email users in my task list where Assigned To is a lookup column that references contacts list with AD users and external vendors(not in AD). When i try to email the users using workflows , if Assigned To has a one name it works fine. But if it has more than 1 name then the users are separated by semicolon or commas depending if i return the field as string, or values comma delimited and the workflow will not send emails to the multiple users.

Is there a way for me to email multiple users if it is a lookup column and not "person or group" column? Maybe separating the names in the lookup column and emailing them individually?

  • Any limits for emails count? – AlexZh May 24 '18 at 13:17
  • @AlexZh Hopefully as many as possible, but probably less than 5 – Kev F May 28 '18 at 1:15
  • 1
    I'd edited answer with new code. Hope it helps. It works on my test SP. – AlexZh May 31 '18 at 13:50
1

If emailto is your lookup.

  1. Add text field resultemails and yes/no field IsNeedToReplace.
  2. In your workflow:

    • resultemails = emailto (as values comma delim)

    • IsNeedToReplace = Yes

    • Wait intil resultemails does not contains ','

    • Email to resultemails

  3. Write powershell script and scheduled it to start every minute.

Use following code to replace value:

        $spSite=Get-SPSite -Identity "http:\\yoursitecol";
        $spWeb=$spSite.OpenWeb();
        $spList = $spWeb.Lists.TryGetList("listname");
        if ($spList)
        {
            $spQuery = New-Object Microsoft.SharePoint.SPQuery;
            #$spQuery.ViewAttributes = 'Scope="Recursive"';
            $spQuery.Query = "<Where><Eq><FieldRef Name='IsNeedToReplace'/><Value Type='Text'>1</Value></Eq></Where>";            
            $spListItems = $spList.GetItems($spQuery);

            if ($spListItems.Count -gt 0)
            {
                foreach($spItem in $spListItems)
                {
                    $spItem["resultemails"] = $spItem["resultemails"] -replace ",", ";";
                    $spItem["IsNeedToReplace"] = 0;
                    $spItem.SystemUpdate();
                }
            }
        }
        $spSite.Dispose();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.