Automatically save an attachment in Outlook 2000

JazzSP8

Well-known Member
Joined
Sep 30, 2005
Messages
1,227
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
Hi All

I was just wondering if anyone knew how I could automatically save an attachement from an Email to a specified location on a network drive?

Or failing that, help with an alternative soloution to this problem;

I've a report that I can only get my having a reporting suite Email it out in CSV format every hour, I then need to get that CSV file imported into Excel so I can take the data from it and incorporate it into a report.

(I can get Excel to retrieve the data file when needed so I thought it would be a case of using Outlook rules to automatically save the attachment to an Email, but, alas it seem's that this isn't an option, not an obvious one anyways...)

As always, any help or advice you guys can give would be greatly appreciated :)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You'll need to adapt this code, but it should work. This code should be placed in the ThisOutlookSession module.

Code:
' register event handler
Private WithEvents MyItems As Outlook.Items

Private Sub Application_Startup()
  Dim olapp As Outlook.Application
  Dim olns As Outlook.NameSpace

  Set olapp = Outlook.Application
  Set olns = olapp.GetNamespace("MAPI")
  Set myitems = olns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myitems_ItemAdd(ByVal Item As Object)

Dim msg As Outlook.MailItem
Dim attachs As Outlook.Attachments

If TypeName(Item) = "MailItem" Then
  Set msg = Item

  ' figure out if it's the message with your attachment

  If msg.Attachments.Count > 0 Then
    Set attachs = msg.Attachs
    ' assumes message has only one attachment
    attachs.Item(1).SaveAsFile path ' wherever you want to save the file
  End If

ExitProc:
Set msg = Nothing
Set attachs = Nothing
End Sub

HTH,
JP

Hi All

I was just wondering if anyone knew how I could automatically save an attachement from an Email to a specified location on a network drive?

Or failing that, help with an alternative soloution to this problem;

I've a report that I can only get my having a reporting suite Email it out in CSV format every hour, I then need to get that CSV file imported into Excel so I can take the data from it and incorporate it into a report.

(I can get Excel to retrieve the data file when needed so I thought it would be a case of using Outlook rules to automatically save the attachment to an Email, but, alas it seem's that this isn't an option, not an obvious one anyways...)

As always, any help or advice you guys can give would be greatly appreciated :)
 
Last edited:
Upvote 0
Thanks JP - Shall have a look at that and let you know how I get on...

Muchly Appreciated :)
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top