Programming Outlook 2007 add-ins with Visual C# 2008 Express
Posted on | September 17, 2009 | 15 Comments
I recently started looking in to creating add-ins for Outlook, as part of a possible project to extend the functionality of MS Outlook 2007 – by far the most popular e-mail client in the business world (when including browser ‘clients’ such as Hotmail and Gmail, Outlook still had 36% market share in the most recent statistics I could find, with Hotmail second at 33%, Apple Mail 5th at 4% while my own favorite Thunderbird is 7th on 2.4% as seen on FingerprintApp.com, which shows similar MS dominance in the consumer market).
As a first part of planning for development on the project, I decided to find out if I could use free tools to create add-ins for Outlook, and started with Visual C# 2008 Express – a free sibling to the popular but costly Visual Studio 2008 (of course you get much more for the paid version, which also made even the trial version too big a package for me to download on the road with mobile broadband), for which you can use for example Visual Studio Tools for Office (VSTO) and Add-in Express for quick development. Furthermore, considering I was new to development for MS Office, I believed that having fewer advanced tools would give the chance to learn more about this type of development, thereby giving skills I wouldn’t find by going the easiest way, and also leading to fewer coding mistakes down the line…
Whether I’m right or wrong in the choice is for each to decide on his/her own, and either way I found a way to create Outlook add-ins with free tools. I started off by following two different blog posts (see references at end of post) which were both written for older versions of Visual C# Express and Outlook. Since the posts were a bit dated (or perhaps for other reasons), the described development was a incomplete, and further investigation had to be made. To make a long story short, what I needed to do was to create a Class project, add references to
- Microsoft Office 12.0 Object Library (COM, shows up as Microsoft.Office.Core)
- Microsoft Outlook 12.0 Object Library (COM, Microsoft.Office.Interop.Outlook)
- System.Windows.Forms (.NET, keeps same name)
The code I ended up with for a simple “Hello World” was a as follows:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Extensibility;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
namespace OutlookAddinSample
{
public class Connect : Object, IDTExtensibility2
{
private Application applicationObject;
private object addInInstance;
private CommandBarButton toolbarButton;
Explorer currentExplorer = null;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst,
ref Array custom)
{
applicationObject =
(Microsoft.Office.Interop.Outlook.Application)application;
addInInstance = addInInst;
if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
{
OnStartupComplete(ref custom);
}
}
public void OnDisconnection(ext_DisconnectMode
disconnectMode,
ref Array custom)
{
if (disconnectMode !=
Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
applicationObject = null;
}
public void OnAddInsUpdate(ref Array custom)
{
}
public void OnStartupComplete(ref Array custom)
{
CommandBars commandBars =
applicationObject.ActiveExplorer().CommandBars;
try
{
this.toolbarButton =
(CommandBarButton)
commandBars["Standard"].Controls["Hello"];
}
catch (System.Exception)
{
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value);
this.toolbarButton.Caption = "Hello";
this.toolbarButton.Style = MsoButtonStyle.msoButtonCaption;
}
this.toolbarButton.Tag = "Hello Button";
this.toolbarButton.OnAction = "!<MyAddin1.Connect>";
this.toolbarButton.Visible = true;
this.toolbarButton.Click +=
new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
this.OnToolbarButtonClick);
}
public void OnBeginShutdown(ref Array custom)
{
this.toolbarButton.Delete(System.Reflection.Missing.Value);
this.toolbarButton = null;
}
private void OnToolbarButtonClick(CommandBarButton cmdBarbutton, ref bool cancel)
{
MessageBox.Show("Hello World", "My Addin");
}
}
}
Sorry about the code formatting, but hopefully it helps someone on getting started. After creating your project with the code for your Outlook add-in, you need to make it visible for the COM and make it strongly typed by signing. The signing is done simply by going to the project Properties (right-click on your project in the Solution Explorer) and then to Signing, where tick Sign the assembly and make a new key file (assuming you don’t have one already). For COM visibility, you go to the Application tab in the properties, click the Assembly Information button and tick the checkbox “Make assembly COM visible”. To make mine work I also took a couple of steps which were not recommended in the post I found information from, so try without the following first:
Under the Build tab, check “Register for COM interop”
Furthermore, the article I followed recommended adding to the registry (start->run->”regedit” on Windows Vista) at the location HKEYLOCALMACHINE\SOFTWARE\Microsoft\Office\Outlook\Addins which didn’t work for me, and I instead added lines at HKEYCURRENTUSER\Software\Microsoft\Outlook\Addin. The added keys under () OutlookAddin.Connect (in my example with namespace OutlookAddin and class Connect; i.e. namespace.mainClass) were
- (STRING) “Description” = “Mail@rchive for Outlook”
- (STRING) “FriendlyName” = “Mail@rchive for Outlook”
- (DWORD) “LoadBehavior” = 00000003
Finally, to make a readable library of your add-in, and to register the installation folder to be used, copy the regasm.exe file (I found mine under C:\Windows\Microsoft.NET\Framework\v2.0.50727, although .NET 3.5 is used in the project) to your [project path]/bin/release, navigate to that folder in your command prompt (start->run->cmd) and run:
- regasm OutlookAddin.dll/tlb:OutlookAddin.tlb /codebase
(this of course only if your dll is named OutlookAddin.dll and you want the tlb to have the name OutlookAddin.tlb)
Following this procedure should add a button to your toolbar saying “Hello”, and when clicking it should pop up a “Hello World” form. If you have any questions or can’t make it work feel free to post a comment.
References:
- Frans King: Creating an Outlook Addin with C# Express
- Dan Crevier: Hello World Outlook Add-in using C#
Google Developer Day
Posted on | September 17, 2008 | No Comments
I was at the recent Google Developer Day at Wembley, and got a few ideas when listening to talks regarding development in Google Maps from the past six months:
-  It is now possible to integrate Google Earth as a map type of Google Maps – something they didn’t tell us enough about imho. However, it seems like this is still at an early stage..
- If you’ve never been to a Google Developer day I would certainly recommend it – even if you know the API’s and have talked to many of the Google people who develop the app’s you use, there’s no better chance of finding other people giving fresh views of the world.
- According to one speaker, using ‘usual Google maps’ gives you a 50 kb download, while the Ajax downloader gives you a 4kb download. A significant claim which I hope to get the chance of testing soon enough – at least within the next few months. Too bad it seems to have a limit of 50 markers..
Of course, there were also a few other interesting subjects, including for example OpenSocial and especially Gears – but that’s not for this post…
Upgrading Wordpress
Posted on | February 12, 2008 | 2 Comments
For a while now, I’ve been in need of upgrading the Wordpress installation for this blog, especially after reading an article over at CyberNet about how easy it was to access old posts with the version I’ve been using. When finally getting around to doing it, I found that an upgrade to Wordpress is one of the easiest things you can do – just follow these simple steps:
- Download, upload and activate wp-db-backup if you don’t have it, and make a backup copy of the database
- Disable all plugins (there’s a link for that at the bottom of the Plugins page, no need to do it one by one)
- Delete all files (no folders yet) except .htaccess and wp-config.php in the root of your install
- Delete wp-admin and wp-includes folders with content
- Upload the files and folders you deleted, from the latest WP version
- Go to (blog.url)/wp-admin/upgrade.php
- Click the link, wait a few seconds and you’re done
One 2D Photo, One 3D Model
Posted on | February 2, 2008 | No Comments
I am not often impressed by what people call new technology or “inventions”, as I often find that these things are simply built on existing knowledge and/or modifications/combinations of what was already in place. In other words, many of the things becoming popular today already existed in a somewhat different shape, such as cell phones being created before the iPhone, portable mp3 players before the iPod, search engines before WebCrawler and music before CD (alternatively tape or LP if you’re not in the youngest generation, or mp3 if you feel CD is outdated)
To continue the thought I started with, most “inventions” are not new, and most thoughts build on the ideas of others. This is one of the reasons why I am not often impressed. Whatever you do, someone has probably done it before (I am more innovative than most people, so decided not to say “whatever we do”), but with the right marketing and contacts you will still have a great chance of succeeding with the idea.
Returning to the original thought yet again, what impressed me for the first time in a couple of years was a site from Stanford University, claiming to create 3D model from single photos – something anyone in the area of Computer Vision (or related) knows is close to impossible without at least some manual work. The site however claimed that you simply uploaded the image and you would get a 3D version back. The following is what I got back (you may need a plugin for viewing VRML content)
In the end, it took 1-3 days (actually I thought it failed after I uploaded a photo from Dublin) before I got the results, making me wonder about their method of 3D extraction from the single image I provided. There are after all relatively simple algorithms which lets you define a great number of points (i.e thousands of points) in the image which builds on estimates and probability (simplification, I know). Since the result impressed me a bit, I decided to look through their publications, and will try interpreting it in “plain english” to see if they have found something which I believe could revolutionize the way computers interpret single images and video streams, or if the this is simply yet another experiment on the way to greatness.
Thinking about what’s related, Microsoft is working on a tool (Photosynth) for creating 3D models from collections of photos. Although the creation of a model involves relatively advanced algorithms (I studied many ways of approach both in my thesis and in various projects) a glance at the work makes me think their algorithms needs much time and processing power, and too many photos for an average user. In other words, it’s not something for a startup to hope for without a budget. As another early impression, I find an interesting part in how they created the feature recognition, since many parts of the image analysis should be greatly helped by understanding the scene. On the BBC site:
It picks out distinctive features in each image and cross-references them against the other photographs, checking for similarities.
As a final note (a bit off topic), I would like to apologize to one of my readers who asked about using the POSIT object with OpenCV. I have only looked into this a few times but never actually used it more than for a few quick test runs, but since your question made me think a bit I decided to have a look as soon as I can after moving (I am actually in the process of packing and preparing for an ineresting move to an interesting move to a new country, which is the main reason I haven’t been able to answer the question). Until then, I recommend the Yahoo OpenCV group. I would be interested in reading/hearing about any findings you make, and wish you the best of luck in finding the answer you seek.
GTD – Getting Things Done
Posted on | January 17, 2008 | 1 Comment
As mentioned before, I’ve been looking a bit at “GTD mentality” (GTD means “Getting Things Done”, basically it’s about ways to be more efficient) lately, and even though I was already effective and doing many of the actions I found recommended, I decided to try a few more. This basically means I’m currently trying out a few different online apps to help de-clutter my mind. Besides starting to note more in my calendar, I’m trying out Remember The Milk (RTM) and Vitalist as task management systems, while also easily integrating them in my Google Calendar to see deadlines for current tasks.
RTM is a system I see as focused on todo lists, more than a complete task management. I enjoy being able to tag each task without having to define the tag before, the integration with other tools (GMail, Google Calendar) is good and simple, which is also the case when adding tasks to the predefined categories. That is, the addition of tasks is simple, but I find it a bit lacking when wanting to specify more about a task I added – when moving my mouse over the list I find that I’m suddenly on another task, instead of simply highlighting the latest task and let me edit date and tags, write notes, share the task, specify a url etc – in other words, the basics. A big plus for RTM is that it’s a free service. I’ve used RTM for work tasks, where most projects have a similar theme, meaning it’s easy to simply keep them in the work tasks and separate by using tags.
Vitalist let’s you specify your own projects and sub-project, ticklers, tasks for “some day”, add new tasks by Jott (speech to text service, seems only to be working in US though) besides giving the possibility to show your tasks in your online calendar, although with the downside of not being able to edit or add tasks through the calendar (at least not as far as I’ve seen, using Google Calendar). As a side note, I’ve been using Vitalist for my home tasks, having multiple projects which are not similar – here I can differ between various projects and contexts, besides the handy multi-level project interface.
The verdict between those two system is relatively equal, leading me to give 3/5 as a rating for each of the services. I will probably try one or two others soon, such as Toodledo, Ta-da List or Todoist, although I’m taking the Todoist warning seriously: “High usage of Todoist may result in an organized life”. All the five mentioned systems seem to have good integration with other online app’s which help you getting things done, such as online calendars, email and other, and in true “Web 2.0″ spirit, of course most have an API if you want to do something in your own way, for example by mashing them all up together with the calendar of your choice, an email system (or a few) and of course put it all together with a good context interpreter (”if you are going to do this, maybe you should remember to do that other thing first”) – we all know from ProgrammableWeb’s 600 API:s that the possibilities are vast, and few categories are missing…
While on the subject of being productive and efficient, three of my favorite blogs often have articles on the subject, with lifehack.org’s “50 Simple Ways To Stay Productive“, Zen Habits “10 steps to becoming an email ninja” and Lifehacker’s “Newsreader showdown” as examples from this and last week. I find reading articles from those three blogs a nice start of the day, and would recommend subscribing to anyone.
Timelapse Photo video
Posted on | December 21, 2007 | No Comments
I found a great video with perfect music a few days ago, and simply can’t stop watching and listening! The video is made by shooting photos with 2 hour intervals at the same location for a year – giving us a video showing battery park day and night, autumn, winter, spring and summer; an incredible result IMHO. I found the video at Photojojo
Photojojo’s Time Lapse Video of Bryant Park from Photojojo on Vimeo.
In the summer I spent an afternoon on the balcony, reading a book while shooting a photo approximately once every second minute, just to see the effect of those photos when flipping through them fast (and of course, I some days have a difficulty in doing only one thing at a time). Now I feel inspired not only to make a short video with that set of photos, but also set up my good old webcam to create a jpg every 30 minutes and make a video from that…
Lifehacking
Posted on | September 12, 2007 | No Comments
Lately, I’ve been enjoying my mornings with reading ‘lifehacking blogs’, such as the popular Lifehacker, lifehack.org and Zen Habits, which give short and tips and tricks for living your life to the fullest. I can recommend reading about for example ‘How not to Multi-task‘, ‘Live the life of a Champion‘ and how to ‘Clean your home in 19 minutes‘. It seems like they have tips for anything in your offline life, and often also for getting more productive online.
Some of the best tips I’ve found in there are to find goals for your life to help motivating the changes you need, never bring work to home, but work on creating your future, and get rid of things that clutter your life. So find or remember your goals now, and find the way to practice them, and use them to create or do something productive you can show – if you don’t have any ideas of what to do in the area there’s always sites online you can look at to help you with simply getting ideas or to brainstorm by yourself or in groups, there’s tools for everything.. You can find tips for that in other posts on this blog, or at the Lifehacking blogs I linked to at the start of this.
Languages and Learning the web
Posted on | September 4, 2007 | No Comments
Lately, I’ve been thinking about improving my Spanish, so when I stumbled upon the site SpanishSense, which contains lessons with voice dialogs, podcasts and help material I became pretty excited. One thing I really like about the site is how they allow you to embed lessons in your own site, to spread the word and build a community where everyone can help eachother in the learning process. According to the site, they also have Chinese lessons, but I’ll wait with looking into that for now – after all, it’s easy getting those new languages confused with the five I already know (six if you count beginner spanish that I didn’t practice for 2-3 years). You can try one of the SpanishSense lessons (introductions) by using the player I put in this post…
Another thing I did to find ways of improving my Spanish was to add a tab called Spanish to my iGoogle page – which of course gave quite a few widgets to use, including a dictionary, Babelfish and news in Spanish.
In other news, I’m looking around at a lot of Web 2.0 sites lately, getting some invites here and there (often found through Mashable), getting updated on new web API:s through ProgrammableWeb while in the process of starting one new site and one new blog. Meanwhile I’ve learned more about Google maps API (including the AJAX version), tiny mce (there must be ways of doing it better, but since it’s popular I guess they’re on to something), Community Server (I’m not very impressed), Dapper, Yahoo! pipes, Google trends and some add-ons for Firefox and Thunderbird. Next is to learn some more about the Google Mashup Editor and perhaps OpenKapow for the site I’m creating. Together with Dapper and Yahoo! Pipes I believe those tools can make wonders…
Maps – the Google version
Posted on | July 27, 2007 | No Comments
This is just about the maps for now, not about stand-alone software like Google Earth.
I’ve become impressed by the Google Maps API when working with it, by the support from the Google team and by the constant feature updates we keep getting – and of course by many of the extensions from the community.
I’ve tried out PdMarker, Clusterer and a few other extensions with varying results, and believe some of those features should be part of the standard API. Today I actually saw in one of the Google groups threads that some of those features will come to us soon, and especially the marker.onHover() for tooltips and marker icon change seems to be on its way.
As a way of learning the API I’ve followed some of Mike’s tips for managing the maps – and noticed it seems very updated (I haven’t seen any dates) – as well as following the official blog, looking a lot at the docs and sometimes checking out Google Maps Mania.
Even though I’m impressed by the maps, marker overlays, geocoders etc I am also a bit disappointed in the fact that I noticed this technology slowing my browser, and in conjunction my entire system, down so I can’t work at normal pace. Of course I understand it takes a bit of code to get it all running, but it seems to me there are still some memory leaks – and I really don’t like the message about ‘unresponsive script’ Firefox tells me about every time I exit the browser after looking at maps for a while….
I’m looking forward to the next update – but even more, I’m looking forward to GMap3(), hopefully with better OnUnload()…
I wish you a nice mapping..
GeoWeb – Mapping the Web
Posted on | July 19, 2007 | No Comments
Lately I’ve been tinkering a lot with maps and what is called the GeoWeb by some. I’m starting to master the API for google maps, geocoding addresses, airport locations etc through different services and creating my own maps showing markers and marker clusters to show locations for hotels, car rental offices and airports, as part of my job. While doing this I’ve also had the chance to discover much more of the GeoWeb, seeing a webcam over Trafalgar Square in London (which is placed wrong on the map) and a couple of creative mapmaking and tour creating sites, making me believe a great deal in the GeoWeb, and in the future both for services such as Google Maps and free software like Google Earth.
Some creative people use a map as a CV, a WikiMapia project was started to let anyone add information on maps – giving it so much information that my old laptop can barely move the map – and you’ve probably noticed the Google maps flight simulator, Goggles. You can find where you would end up if digging a hole through the planet from any position – I would end up in the middle of the pacific ocean if I started digging from here, so I guess I’ll skip that for now.
While creating my own maps with overlay, I’ve noticed it’s very simple javascript which helps us control the maps, overlays, events etc, and am now considering creating my own mashup using maps and some other services – doing something I haven’t seen around, at least not in Europe – but that will be a secret for now, until the plans start coming to life…
Happy mapping, and have a great weekend – I know I will, going to another place on the map…












