Saving attachments to disk using rules?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm trying to find a way to automatically save specific excel files attached
in an email to a folder on the PC. Outlook rules do not appear to include
this. Unfortunately my VB skills are very limited and I have been unable to
implement the previous solutions found in this board.

I have looked at some 3rd party software but after a little research realise
that a macro could be coded to achieve this. However in the long run 3rd
party software may be easier and I am open to any recommendations.

Emails arrive in the customers Inbox from a couple of specific senders
containing an excel file and we wish to automatically (if possible) save
these to a specific location for extraction into an Access database. I guess
I would be looking at finding *.xls and an object to specify the senders

I would appreciate your assistance in achieving this We are using Outlook
2003.

Many Thanks

Matt
 
These samples show various ways to save attachments:

http://www.fontstuff.com/outlook/oltut01.htm
http://www.outlookcode.com/codedetail.aspx?id=70
http://www.slovaktech.com/code_samples.htm#StripAttachments

If you're using Outlook 2002 or later, you can write less code by using a "run a script" rule action to execute a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
For Each att in msg.Attachments
att.SaveAsFile "c:\" & att.FileName
Next

Set att = Nothing
Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top