Information is all over – emails, blogs, notes, posts. While I consolidate incoming information in my Inbox (My Pipeline Is My Inbox) it may end spread all over in my OL folders. Even if I had one folder for all – it is collection of mail items, but not single document. What I would love to have is an ability to generate documents from these mail items and then share it.
Here are 5 steps I’ve taken to create this ability that lets me now generate documents directly from Outlook 2007.
- Have Visual Studio 2005 installed
- Download and install VSTO SE
- Download code sample from https://channel9.msdn.com/ShowPost.aspx?PostID=259129#259129. The sample shows how to add menu item to Outlook 2007
- Here is what I have in my Outlook 2007 after installing the addin I created using the sample:
- In event handler run through some folder, concatenate its contents, and save to the file
//THE FOLLOWING CODE IS REALLY DIRTY…. I HAVE 12 PST’s, so I am picking the last one and second folder in in it. Use you imagination to make it more flexible.
Outlook.MAPIFolder inBoxfolder = Application.Session.Stores.GetRootFolder().Folders;
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= inBoxfolder.Items.Count; i++)
if (inBoxfolder.Items[i] is Outlook.PostItem)
Outlook.PostItem pi = (Outlook.PostItem)inBoxfolder.Items[i];
using (StreamWriter sw = new StreamWriter(@"C:\GeneratedFile.htm"))
Here is the scenario where I can apply it.
I am dev team lead and I want to share some rough thoughts on AJAX with my team. I go ahead and subscribe to couple of feeds for the subject (more on that here - How to Use Outlook 2007 RSS To Effectively Aggregate And Distill Information). Now I have some blog posts about it in my Outlook 2007, I drag it into resulting folder – the one that the above code handles. Then I add some private collection on the subject by pressing Cntrl+Shift+S (more shortcuts here My Favorite Shortcuts) and paste there AJAX links. Here is how AJAX collection might look:
Then I run the code I developed using VSTO and it generates nice HTML doc. One obstacle though (hypothetically) – I cannot send it to the team since the only document format I can send is PDF, so I copy-paste ( which is my favorite design pattern – more on patterns here AOP, Pipelines, Interceptors, and HttpModlues) the contents into Word 2007. While I am in Word 2007 I decide to add nice table of contents and then convert it into PDF.
I am all set to share the document with the team. Want it too? Here it is.
Thanks Oren for helping me with VSTO.