title: Get appointment from Office365 in C#.Net
body: <p>Basically, My Knowledge level in Office 365 at Beginning level. </p>
  
  <p>I am trying to pull the appointment from Office 365 through .Net Office 365 API call and show it in Windows Application Grid. </p>
  
  <p>I am using code(below) to pull the appointments; I have collected the code from web...</p>
  
  <p>I have succeeded till authentication part. I can view the authenticate success message and Office 365 calendar properties like <code>FromTime</code>, <code>Location</code> etc. But I am not able to receive the data. It returns <code>System.Nullable DateTime Exception</code>.</p>
  
  <pre><code>namespace GetCal
  {
      public class CalendarAPISample
      {
          const string ExchangeResourceId = "https://outlook.office365.com";
          const string ExchangeServiceRoot = "https://outlook.office365.com/ews/odata";
  
          public static async Task&lt;IOrderedEnumerable&lt;IEvent&gt;&gt; GetCalendarEvents()
          {
              var client = await EnsureClientCreated();
              string fromdate = "01/01/2014";
              DateTime datet = Convert.ToDateTime(fromdate);
  
              // Obtain calendar event data
              var eventsResults = await(from i in client.Me.Events
                                         where i.End &gt;= datet //DateTimeOffset.UtcNow
                                    select i).Take(10).ExecuteAsync();
  
              var events = eventsResults.CurrentPage.OrderBy(e =&gt; e.Start);
              //return events.ToList().ConvertAll(new Converter(ent =&gt; ent));
              return events;
          }
  
          private static async Task&lt;ExchangeClient&gt; EnsureClientCreated()
          {
              Authenticator authenticator = new Authenticator();
              var  authInfo = await authenticator.AuthenticateAsync(ExchangeResourceId);
  
              return new ExchangeClient(new Uri(ExchangeServiceRoot), authInfo.GetAccessToken);
          }
  
          public static async Task SignOut()
          {
              await new Authenticator().LogoutAsync();
          }
  
          public CalendarAPISample()
          {
              // TODO: Complete member initialization
              try
              {
                  // call the authenticator
                  var x = GetCalendarEvents();              
  
              }
              catch (Exception ex)
              {
                  Console.WriteLine(ex.Message);
              }
          }
      }
  }
  </code></pre>
  
  <p>In the <strong>EVENTS</strong> objects contains <code>IEnumerable</code> datatype values. I want convert <code>IEnumerable</code> to <code>DataTable</code>. </p>