title: Read facebook message box
body: <p>I am using Facebook.dll i.s FacebookClient , Mainly I want to read Facebook user mail box I have auth token saved in db. </p>
  
  <ol>
  <li>Select messages (all) from mail box where I can mention start date and end date</li>
  <li>Save all messages in db </li>
  </ol>
  
  <p>I have used</p>
  
  <pre><code>dynamic result = objFacebookClient.Get("fql",
                       new { q = "SELECT message_id, author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)" });
  </code></pre>
  
  <p>Is it possible get result as</p>
  
  <ul>
  <li>Message - Content of message</li>
  <li>Send t o- Sender name and id</li>
  <li>Receive By - Name and id</li>
  <li>Create Date - Message create date</li>
  </ul>
  
  <p>Code is here </p>
  
  <pre><code>dynamic result = objFacebookClient.Get("fql",
     new { q = "SELECT message_id, author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)" });
  List&lt;Model.FacebookUserMessageInfo&gt; objFacebookMessageList = new List&lt;Model.FacebookUserMessageInfo&gt;();
  if (result != null)
  {
      Model.FacebookUserMessageInfo objFacebookMessage = null;
      var values = result.Values;
      var TotalResult = (((System.Collections.Generic.Dictionary&lt;string, object&gt;.ValueCollection)values).ToList()[0]);
      var TotalMessagesData = (JsonArray)TotalResult;
      if (TotalMessagesData != null)
      {
          foreach (var Messages in TotalMessagesData)
          {
              objFacebookMessage = new Model.FacebookUserMessageInfo();
              objFacebookMessage.MessageText = (((JsonObject)Messages)["body"]).ToString();
              objFacebookMessage.ActionUserID = Convert.ToInt64(((JsonObject)Messages)["author_id"]);
              if (objFacebookMessage.ActionUserID == CurrentUserId)
              {
                  objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Sent.ToString();
              }
              else
              {
                  objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Receive.ToString();
              }
              objFacebookMessage.FacebookUserId = FacebookUserId;
              var MessageSecond = (((JsonObject)Messages)["created_time"]).ToString();
              var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
              objFacebookMessage.CreatedDate = dateTime.AddSeconds(double.Parse(MessageSecond));
              objFacebookMessageList.Add(objFacebookMessage);
          }
      }
  }
  </code></pre>
  
  <p>Thanks in advance</p>