Link to home
Create AccountLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

How can I save an attachment from an RSS Feed folder

I have subscribed to an RSS Feed of MP3 files that I save in a sub folder of my RSS Feeds folder called "Italian Mags MP3".  Each email contains an MP3 file and the first line in each email contans a code that identifies the file in the format  "a MP3 yyyy-mmn" where
    a is a two or 3 character code,
    MP3 is a constant  
   yyyy-mm is the year and month of the file and
   n is a further identifier of the file

What I would like is do develop an Outlook Rule or a VBA macro that runs as soon as the RSS Feed is updated that will save the attachment in a folder on my PC based on the month (mm) content of the first line of the email. Specifically the path would be C:\Users\Rob\Music\Italian\mm where mm is the month corresponding to the mm in the date component of the code.

If necessary I can easily write a VBA function that will extract the mm component I am looking for, but what I don't know is the best and easiest way to accomplish the rest, or if it is even possible.

I guess I need something that will
   Check RSS Feeds as soon as they hit this folder
   Run my function to determine the mm content
  Save the attachment in the appropriate folder

Can anyone suggest how I do this, of if I am asking too much of Outlook
Avatar of Rob4077
Rob4077
Flag of Australia image

ASKER

Actually I just found an easier way to identify the month. The month can simply be identified as the month of the date when the file was sent
ASKER CERTIFIED SOLUTION
Avatar of terencino
terencino
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Rob4077

ASKER

Hi Terry,
That is absolutely amazing!!!! I changed the code to take the date from the alternative you proveded, namely Month(Item.ReceivedTime), as it proved more reliable, but apart from that it worked first time. Thank you so much.

I am familiar with basic VBA code but what I don't understand is how the watch works. How did you know what code to use to watch for the arrival of an email into the feed (Sub m_outlookFolderItems_ItemAdd(ByVal Item As Object))? There must be somewhere that shows/lists the varous watches you can add to code.

Anyway I am very grateful that you put this together for me.
Ha I'm amazed it worked first time, it is a credit to how well you have detailed your question.  I'm not all that familiar with VB so I learned quite a bit myself in the process, and it is only the tip of a very large iceberg I expect. When an item is moved to a folder it triggers a number of "events" (one being folder_ItemAdd) which is "handled" by Outlook. The WithEvents & Initialize_Handler code above allows the event to be detected by the programmer as well. There are lots of events, I just had a look in VBE at View > Object Browser. I'm going to hunt down some articles to help me transition a bit further along with VB, it is really powerful, and as you can see it works happily with VBA.

Cheers
...Terry
Avatar of Rob4077

ASKER

Thanks Terry, appreciate help very much, and the explanation of where to find more information. Like you I will have to hunt down some more information.