In my application I need to be able to monitor a folder (not the
inbox)
When a email is moved to that folder with an attachment I want to save
the attachment to a fixed location and then delete the email.
I can find loads of examples of how to make a document and attach a
file but can't find how to make it go the other way.
Any help would be very much appreciated
My very first Macro did something similar to this. Since it is my only
macro to date, I have to admit that I'm not an expert, but I'll try to
answer your question to the best of my ability.
I think if you take a look at the 2002 Outlook Object model (take a look
at pdf linked to
http://www.microeye.com/resources/ObjectModel2002.htm)
and work your way backwards, you'll find that an Attachment object and
all its methods (SaveAsFile) belongs to the Attachments collection
property of an Item object, which itself belongs to the Items
collection.
The Items collection property belongs to the MAPIFolder object, which
can be instantiated by several methods from the NameSpace object
(GetFolderFromID or PickFolder might be suitable for you).
The NameSpace object is instantiated from the Application object.
So in pseudocode, it might look something like this:
Get Outlook Application Object
Get Namespace Object From Outlook Application Object
Get MAPIFolder object from Namespace Object -- Pointing to your folder
For each Item in the Items Collection From the MAPIFolder object
For each Attachment in the Attachments collection from Item object
Save Attachment to "insert path"
Next
Delete Item
Next
I think in both loops you have to count down because every time you
delete something from a collection the index gets reset and if you don't
count down, you can skip around in the object. At least that's what
I've learned from Sue Mosher.