title: How to get the recipients of an email using EWS
body: <p>I am struggling to get the recipients of an email.</p>
  
  <p>I understand that the Recipients is an array, so I need to put them into an array, but my code will not compile:</p>
  
  <pre><code>do
  {
  // set the prioperties we need for the entire result set
  view.PropertySet = new PropertySet(
      BasePropertySet.IdOnly,
      ItemSchema.Subject,
      ItemSchema.DateTimeReceived,
      ItemSchema.DisplayTo, EmailMessageSchema.ToRecipients,
      EmailMessageSchema.From, EmailMessageSchema.IsRead,
      EmailMessageSchema.HasAttachments, ItemSchema.MimeContent,
      EmailMessageSchema.Body, EmailMessageSchema.Sender,
      ItemSchema.Body) { RequestedBodyType = BodyType.Text };
  
  // load the properties for the entire batch
  service.LoadPropertiesForItems(results, view.PropertySet);
  
  e2cSessionLog("\tcommon.GetUnReadMailAll", "retrieved " + results.Count() + " emails from Mailbox (" + common.strInboxURL + ")");
  
  foreach (EmailMessage email in results)
  
  // looping through all the emails
  {
  
      emailSenderName = email.From.Address;
      sEmailSubject = email.Subject;
      emailDateTimeReceived = email.DateTimeReceived.ToShortDateString();
      emailHasAttachments = email.HasAttachments;
      ItemId itemId = email.Id;
      emailDisplayTo = email.DisplayTo;
      sEmailBody = email.Body; //.Text;
      Recipients = email.ToRecipients;
      ....
  </code></pre>
  
  <p>the last line there will not compile, as apparently I cannot implicitly convert the collection ToRecipients to a string...</p>
  
  <p>so I tried to loop through all the ToRecipients:</p>
  
  <pre><code>string[] Recipients;
  for (int iIdx=0; iIdx&lt;-email.ToRecipients.Count; iIdx++)
  {
      Recipients[iIdx] = email.ToRecipients[iIdx].ToString();
  }
  </code></pre>
  
  <p>but I have obviously not declare this properly, as it won't compile with the message that <code>Recipients</code> is unassigned.</p>
  
  <p>What is the correct way to assign this?</p>
  
  <p>I need to be able to use the recipients again later - for example to send them a 'heads up' email about a problem for example.</p>