Wednesday, October 11, 2006 12:18 PM
How can I see if a MailItem is a RSS item using the object model?
Wednesday, October 11, 2006 12:55 PMModeratorIn Outlook 2007? RSS feed items are PostItem with MessageClass = "IPM.Post.Rss" -- not MailItem.
Wednesday, October 11, 2006 1:36 PM
Yes, I'm using Outlook 2007 and VSTO2005SE.
Is the Application_NewMailEx event the best way to get new RSS items? If so, how can I check what type the
returns? What is the best way to check the type and cast it to PostItem? Now I use Outlook.PostItem post = item as Outlook.PostItem and then check to see if this is null. If not, I check if it's a IPM.Post.Rss.
However, Application_NewMailEx don't seem to fire for new RSS items.
Wednesday, October 11, 2006 1:54 PMModerator
As its name implies, I would expect the NewMailEx event to fire only for new mail. RSS feed items are not mail. You should be able to use the Folder.Items.ItemAdd method to monitor RSS feed folders for new items. What is it that you want to do with these items?
I don't write C# code, so I can't speak to the best way to check the type and cast.
Wednesday, October 11, 2006 2:04 PM
Thank you. Setting and Item_Add event handler on the DefaultFolder for RSS Subscriptions don't work, so maybe I have to set it for each subfolder? What do you think?
What I hope to achieve is to check for new feeds and check them for padcasts attachment. If the feed is a podcast feed and the item contains an attachment I would like to download it and add it to a playlist in Windows Media Player.
I thought this would be a quite simple project just to learn more about writing addins for Outlook and on the same time something I'd really like to have.
Thank you so much for your help both here and on Outlookcode.com.
Wednesday, October 11, 2006 2:06 PMModerator
Yes, of course you need to set up an event handler for each folder you want to monitor.
Your project sounds like a great practical application for playing with the new Outlook 2007 features and VSTO 2005 SE.
Wednesday, October 11, 2006 3:26 PM
It's actually quite amazing! I've never programmed Outlook before but I managed to get a working prototype of this working in just two hours. (I have programmed alot for Word, Excel and ASP.NET)
Now I just have to get a nice UI to select where mp3-files should be saved and create playlists in WMP.
Is it possible to get the actual rss feed from a folder in some way? It would be nice to only hook up event handlers for feeds that really is a podcast feed and make sure that it downloads enclosures automaticly for just these feeds.
Wednesday, October 11, 2006 4:01 PMModerator
Sounds like you're having fun!
I haven't found where Outlook is storing the feed list yet, although I know it's somewhere in the default information store.
However, each feed folder has a hidden message containing information about the feed, which you can access as a StorageItem object. The MessageClass is IPM.Sharing.Binding.In, and the Subject holds the URL for the feed, so with a little VBA prototyping:
Set fld = Application.ActiveExplorer.CurrentFolder
Set si = fld.GetStorage("IPM.Sharing.Binding.In", _
If Not si Is Nothing Then
BTW, if you enjoy this kind of digging, get yourself a copy of Outlook Spy or MFCMAPI.exe.
Wednesday, October 11, 2006 6:44 PM
Yeah, I'm having great fun. As you saw on my post on Outlook Code I hade to write an addin in VB6 for a client. Going back to VB6 after doing .net since the first beta really sucked. I just had to do something not so 1997 to wash away that awful VB6-smell from my fingers.
I'll look in to Outlook Spy! Thanks for the tip and all your help!
Btw. This is probably super simple, but how do I get hold of the currently selected item? (mailitem, postitem or what ever) Is there something like the Selection-property in Word and Excel?
Wednesday, October 11, 2006 10:00 PMModerator
Johan Nordberg wrote:
This is probably super simple, but how do I get hold of the currently selected item? (mailitem, postitem or what ever) Is there something like the Selection-property in Word and Excel?
Depending on what you mean by that, Application.ActiveExplorer.Selection (a collection) or Application.ActiveInspector.CurrentItem.