public void RenderEmails()
    {
        var html = new StringBuilder();


        // Get the data
        var service = new MessagesService();
        var emails = service.GetEmails(FolderID);

        var settings = ExigoApiContext.CreateODataContext().Customers
            .Where(c => c.CustomerID == Identity.Current.CustomerID)
            .Select(c => c);
        
        // Assemble the emails list
        html.AppendFormat("<table class='table messageslist'>");

        if(emails.Count == 0)
        {
            html.AppendFormat("<tr><td colspan='5'><p class='nomessages'>(no messages to display)</p></td></tr>");
        }
        else
        {
            foreach(var email in emails)
            {
                var statusCssClass = (email.MailStatusTypeID == 0) ? "status-unread" : "status-read";
                var hasAttachmentsDisplay = (email.HasAttachment) ? "<i class='icon-file'></i>" : string.Empty;

                var formattedDate = email.MailDate.ToString("MMM d");
                if(email.MailDate.Date == DateTime.Now.Date) formattedDate = email.MailDate.ToString("h:mm tt");

                html.AppendFormat(@"
                        <tr class='{0}' data-id='{1}'>
                            <td class='options'>
                                <input type='checkbox' /></td>
                            <td class='details'>{2}</td>
                            <td class='from clickable'>
                                {3}</td>
                            <td class='summary clickable'>{4}</td>
                            <td class='received clickable'>{5}</td>
                        </tr>",
                    statusCssClass,
                    email.MailID,
                    hasAttachmentsDisplay,
                    email.MailFrom,
                    email.Subject,
                    formattedDate
                );
            }
        }

        html.AppendFormat("</table>");


        // Render the emails
        var writer = new HtmlTextWriter(Response.Output);
        writer.Write(html.ToString());
    }