Packt’s $5 eBonanza returns


Following the success of last year’s festive offer, Packt Publishing will be celebrating the Holiday
season with an even bigger $5 offer.
From Thursday 18th December, every eBook and video will be available on the publisher’s website forjust $5.

Customers are invited to purchase as many as they like before the offer ends on Tuesday
January 6th, making it the perfect opportunity to try something new or to take your skills to the next
level as 2015 begins.
With all $5 products available in a range of formats and DRM-free, customers will find great value
content delivered exactly how they want it across Packt’s website this Xmas and New Year.

Find out more at

Connecting Outlook appointments with Freshbooks web-service data, part 4

In this, our fourth and final part on how to write an Outlook add-in for Freshbooks web-service, we’ll explore how to develop a custom form region to connect an Outlook appointment with the web-service’s Timesheet entry.

Our intended end result will look similar to the following image. You will notice how we’ve used an Add-in Express custom form region to add a Project selection button and a Task selection combo box.

Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Creating Outlook ribbon UI from scratch – Integrating with Freshbooks web-service, part 3

In part one of the series, we’ve created Freshbooks specific folders, set their Message classes and created a Freshbooks Solution Module. In part two we continued by adding custom properties to the folders and created custom views. We’ve also replaced the Outlook Inspector UI with our own and imported Freshbooks data into Outlook.

In this article, we’ll continue with the add-in and tackle the process of hiding the standard Outlook Inspector and Explorer Ribbon tabs for the Freshbooks folders and items and replacing them with our own Freshbooks Ribbon Tabs.

Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Calling Freshbooks web-service from Outlook, part 2

In the previous article, we started with the basic concept and layout of our Freshbooks Outlook Add-in, see Integrating Outlook add-in with Freshbooks web-service, part 1.

So far, we’ve connected Outlook to the web-service by creating the Freshbooks specific folders, message classes and solution module, and in this article we’ll continue building our plug-in by doing the following:

Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Book give-away : Bootstrap for ASP.NET MVC

Stand a chance to win a free copy of Bootstrap for ASP.NET MVC, just by commenting!

This competition is now closed. Winners will be informed via e-mail. Thanks to all for commenting!

For the contest Packt have 3 copies of Bootstrap for ASP.NET MVC, to be given away to 3 lucky winners.

How you can win:

To win your copy of this book, all you need to do is come up with a comment below highlighting the reason "why you would like to win this book”.

Duration of the contest & selection of winners:

The contest is valid for a week from 16 to 24 October 2014, and is open to everyone. Winners will be selected on the basis of their comment posted.

About the book:


This book guides you through the process of creating an ASP.NET MVC website from scratch using Bootstrap. You will learn about various Bootstrap components as well as techniques to include them in your own projects. The book includes practical examples to show you how to use open source plugins with Bootstrap and ASP.NET MVC and will guide you through building an ASP.NET MVC website using Bootstrap, utilizing layout and user interface components. In the process, you will also learn to build ASP.NET MVC HTML helpers and T4 templates as well as how to use the jQuery DataTables plugin. At the end of this book, you will find some valuable tips and tricks, which will help you in getting the most out of your Bootstrap and ASP.NET MVC integrated website.

Book is for ASP.NET MVC developer who would like to know how to incorporate Bootstrap into their projects. Developers with entry-level experience of ASP.NET MVC development and limited experience with Bootstrap will also benefit from this book.

Read more about the book on the Packt Publishing website.

How to integrate an Outlook add-in with the Freshbooks web-service, part 1

Freshbooks is a cloud-based accounting web-service that allows more than 5 million people to capture invoices, expenses and time sheets online. It also provides a rich API which developers can use to access Freshbooks data using HTTP and XML.

In this article, the first of a series, we’ll start building a Microsoft Outlook Add-in that will serve as a client for Freshbooks. Users would be able to view their Freshbooks data as well as perform numerous Freshbooks tasks all from within Outlook.

We’ll cover the following topics in this article:

  • Creating an Add-in Express based Outlook add-in
  • Integrating the Outlook add-in with a web-service
    • Creating web-service specific folders
    • Setting up custom Message classes for the folders
    • Adding the web-service data to Outlook Address books
    • Creating a solution module for a custom web-service
    • Adding the Freshbooks specific folders to the Solution Module

Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Creating an Excel Stock Information RTD server using the Yahoo Finance API

Yahoo’s Query Language or YQL allows you to run SQL-like queries against a variety of web services. The amount of available web services are immense! To get a better idea of all the available services,   which services are on offer, and the type of data they return, have a look at the YQL Console.

In today’s article, we’ll write an Excel RTD server that returns the latest stock prices and other information. In case you’re not familiar with Excel RTD servers, it is used to communicate with a real-time data source, such as stock quotes and provide the user with a constant flow of changing data.

Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Bootstrap for ASP.Net MVC Published!


I’m very proud and happy to announce that my book, Bootstrap for ASP.NET MVC has been published and is available for purchase.

This book guides developers on what is Bootstrap, how to include it in your project and even how to create HTML Helpers as well as T4 templates to generate Bootstrap ready Razor views.

I hope developers will find it a useful resource, and will enjoy the book as much as I enjoyed writing it.




You can purchase Bootstrap for ASP.NET MVC from the following stores:

Calling Yahoo Weather web-service from an Outlook add-in

It’s been a while since my last blog post and today we start the first in a series of exciting blog posts on integrating Microsoft Office applications with web-based services. The web is growing bigger and bigger by the day and there are a wide range of applications and services available on the internet which you can use to provide your users with more features and functionality inside Microsoft Outlook.

In today’s article, we’ll build an Outlook Add-in that displays the current weather conditions and time of day for all recipients of an e-mail using the Yahoo Weather web-service. At the end of this article, our Outlook add-in will resemble the following screenshot:


Read more at Add-in Express.

To see all my recent Add-in Express blog posts visit my author page.

Returning a Crystal report as a PDF ActionResult in ASP.Net MVC

In a recent project I needed to display a generated PDF contract document inside the browser. I found a great article by Patrick Kalkman illustrating how to create a custom ActionResult that converts a HTML string into a PDF using the iTextSharp library.

This seemed like the perfect solution, however, I later found that the conversion from HTML to PDF is not perfect at all and getting your design to look the same in PDF as it does in HTML is not easy. So I found another article by Hasibul Haque, where he shows how to return a Crystal Report as PDF using ASP.Net MVC.

The Crystal Report approach works well, as your design will look perfect. The only problem I had was Hasibul’s approach returned the PDF as a download and I wanted to display it inside the browser. I combined Patrick and Hasibul’s approaches and what I came up with was a CrystalReportPdfResult

The CrystalReportPdfResult is an ASP.Net ActionResult, that return the Crystal Report as a PDF file. The result (using an iframe) looks like this inside the browser:


Creating the CrystalReportPdfResult class

To generate the result as indicated by the previous image, follow these steps:

  1. Create a folder inside your ASP.Net MVC project called Pdf.
  2. Add a new class to this folder called CrystalReportPdfResult.cs.
  3. The new class will inherit from the ASP.Net MVC ActionResult class.

The entire code listing for the CrystalReportPdfResult class follows:

  1. public class CrystalReportPdfResult : ActionResult
  2. {
  3.     private readonly byte[] _contentBytes;
  5.     public CrystalReportPdfResult(string reportPath, object dataSet)
  6.     {
  7.         ReportDocument reportDocument = new ReportDocument();
  8.         reportDocument.Load(reportPath);
  9.         reportDocument.SetDataSource(dataSet);
  10.         _contentBytes = StreamToBytes(reportDocument.ExportToStream(ExportFormatType.PortableDocFormat));
  11.     }
  13.     public override void ExecuteResult(ControllerContext context)
  14.     {
  16.         var response = context.HttpContext.ApplicationInstance.Response;
  17.         response.Clear();
  18.         response.Buffer = false;
  19.         response.ClearContent();
  20.         response.ClearHeaders();
  21.         response.Cache.SetCacheability(HttpCacheability.Public);
  22.         response.ContentType = "application/pdf";
  24.         using (var stream = new MemoryStream(_contentBytes))
  25.         {
  26.             stream.WriteTo(response.OutputStream);
  27.             stream.Flush();
  28.         }
  29.     }
  31.     private static byte[] StreamToBytes(Stream input)
  32.     {
  33.         byte[] buffer = new byte[16 * 1024];
  34.         using (MemoryStream ms = new MemoryStream())
  35.         {
  36.             int read;
  37.             while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
  38.             {
  39.                 ms.Write(buffer, 0, read);
  40.             }
  41.             return ms.ToArray();
  42.         }
  43.     }
  44. }


Creating the Crystal Report

Next, we need to create the Crystal Report that will be returned as a PDF. Do this by following these steps:

  1. Create a new folder called Reports in your project.
  2. Add a new Crystal Report object to the Reports folder. You can find the item template under the Reporting tab on the Add New Item dialog.image
  3. Design the report to your liking and save it.
  4. If you need to install Crystal Reports for Visual Studio 2013, get it here.

Creating the Action that will return the PDF

Next, we need to create the actual Action on a Controller that will return the CrystalReportPdfResult, by following these steps:

  1. Open your controller. In this example, we’ll use the HomeController.
  2. Add a new method called Pdf that will return a CrystalReportPdfResult object.
  3. Inside this method, we’ll build a list of customer that will be used as data for the report and build the path to the report filename. The code for the method follows:
  1. public CrystalReportPdfResult Pdf()
  2. {
  3.     List<Customer> model = new List<Customer>();
  4.     model.Add(new Customer { CompanyName = "Blah Inc.", ContactName = "Joe Blogs" });
  5.     string reportPath = Path.Combine(Server.MapPath("~/Reports"), "rptCustomers.rpt");
  6.     return new CrystalReportPdfResult(reportPath, model);
  7. }


Creating the View

We’ll embed the PDF using an <iframe>, so open a view. In this case we’ll  use About.cshtml and replace it’s mark-up with the following:

  1. @{
  2.     ViewBag.Title = "Customer Report";
  3. }
  4. <h2>@ViewBag.Title.</h2>
  5. <p>This is the customer report</p>
  8. <div class="row">
  9.     <div class="col-md-10">
  10.         <iframe src="@Url.Action("Pdf", "Home")" height="500" width="100%"></iframe>
  11.     </div>
  12.     <div class="col-md-2">
  13.         <h3>Other page content</h3>
  14.         <button type="button" class="btn btn-primary">Click here</button>
  15.     </div>
  16. </div>


Note, that we’re using the @Url.Action helper to set the src attribute of the <iframe> element. This will make a call to the Pdf action on the Home controller and render the result inside the <iframe>

I’ve tested this on the latest version of Chrome, Firefox and Internet Explorer and it works on all of them.

Hope this helps someone that needs something similar. Thank you for reading. Until next time, keep coding!

Download the sample project here.

If you have any comments or questions, please feel free to ask leave a comment or drop me a line on Twitter.

Need help with you next ASP.Net MVC Project?
Do you need guidance with your next .Net project?
Contact me for ASP.Net MVC and .Net software development and consulting.