title: How to Construct the Email To activity in SharePoint 2013 Workflow
body: <p>I am using SharePoint 2013 SP1 and I am having a problem constructing the Email Activity To attribute.  </p>
  
  <p>Here's where I am at.
  I have a created a custom workflow and custom association and initiation form using SharePoint 2013.</p>
  
  <p>My Assn. form is fine.  I pass in the people Editor control (Active Directory group name ie. SharePointApprovers) value to my workflow just fine.</p>
  
  <p>Now on my Init form I use the passed in value from people picker and display a list of users and email addresses from the people picker group.  The list of users and email addresses are listed in a table with a check box to the left of each row. I am using JQuery, Knockout and MVC web service to retrieve the values from the group.</p>
  
  <p>All is well.</p>
  
  <p>Now my users pick who they want to send the email to.  Let's say they pick two users!  This means my variable is like this (<code>firstuser@abc.com;seconduser@abc.com</code>).</p>
  
  <blockquote>
    <p>When the user clicks the submit button, I have <code>JSOM</code> code which
    starts the workflow and sends in the 2 users email addresses as an
    argument to the workflow.  Note:  I tried sending my two emails as a
    array and failed but if I send it in as a string it works.  The
    variable is called strUsers.</p>
  </blockquote>
  
  <p>Since the argument is a string and Email Activity To attribute requires an array, I use the <code>BuildCollection&lt;String&gt;</code> Activity to convert my string strUsers to an array.
  I think this worked, as when I added a WriteToHistory Activity to <strong>my workflow my result in workflow history</strong> is as follows... <code>"The value is firstuser@abc.com;seconduser@abc.com"</code>.</p>
  
  <p>I then configure the email Activity and set to To property to my BuildActivity variable (recipients).  As this is an array.</p>
  
  <p>When I deploy my Visual Studio 2013 solution, and attach my workflow to a publishing page, I am getting this error after I submit the Init form.</p>
  
  <blockquote>
    <p>An unhandled exception occurred during the execution of workflow
    instance.  System.ArgumentNullException.</p>
  </blockquote>
  
  <p>Does anyone know of an example of how to set up the Email To collection value.</p>
  
  <p>PS I have looked at this <a href="http://blogs.msdn.com/b/officeapps/archive/2013/09/18/step-by-step-sending-email-messages-from-a-workflow-in-an-app-for-sharepoint-2013.aspx" rel="nofollow">link</a> but it is only passing in one variable.  In my case I have a string of  emails.  I need to pass in an array to the Email To property.</p>