Windows Live Writer BlogThis macro for Outlook 2007

If you use Windows Live Writer as your blogging tool and Outlook 2007 as your RSS aggregator then you maybe interested in this VBA macro. It will pull the necessary information from the currently selected RSS Item in Outlook and call the Windows Live Writer BlogThis API to create a new post.

Const FEED_URL = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8900001F"
Const FEED_NAME = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8904001F"
Const ITEM_URL = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8901001F"

Sub BlogThis()
    Set liveWriter = CreateObject("WindowsLiveWriter.Application")
    
    If (liveWriter Is Nothing) Then
        MsgBox "It appears that Windows Live Writer is not installed"
        Exit Sub
    End If
    
    If (ActiveExplorer.Selection.Item(1).MessageClass <> "IPM.Post.Rss") Then
        MsgBox "The currently selected item is not a RSS Post"
        Exit Sub
    End If
    
    Dim rssItem As PostItem
    Dim pa As PropertyAccessor
    
    Set rssItem = ActiveExplorer.Selection.Item(1)
    Set pa = rssItem.PropertyAccessor
    
    feedUrl = pa.GetProperty(FEED_URL)
    feedName = pa.GetProperty(FEED_NAME)
    itemUrl = pa.GetProperty(ITEM_URL)
    itemTitle = rssItem.Subject
    itemContents = rssItem.HTMLBody
    
    liveWriter.BlogThisFeedItem feedName, itemTitle, itemUrl, itemContents, feedUrl, _
        authorMissing, autherEmailMissing, publishDateMissing
End Sub

See KC's post for adding this VBA macro as a toolbar button in Outlook or if you would prefer to add this on the RSS item context menu you could add the following to your default VBA project.

Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
    If (Selection.Count = 1 And Selection.Item(1).MessageClass = "IPM.Post.Rss") Then
        Set blogThisBtn = CommandBar.Controls.Add(Type:=msoControlButton)
        blogThisBtn.Caption = "Blog This in Live Writer"
        blogThisBtn.OnAction = "Project1.ThisOutlookSession.BlogThis"
    End If
End Sub

Enjoy!

1 Comment

  • hm, looks like a really MUSTHAVE for me, unfortunately I dont get this to work on Ol2007 fully patched, and LW latest edition.
    Any Hints?
    I do so the Contect menu entry, but clicking on it does.... nothing at all :(

Comments have been disabled for this content.