StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1719621
Impressions6471912
Links
Imprint
Privacy Policy
Contact
Attachments: Save the selection to the harddisk
Author: Michael BauerHomepage
Date: 29.07.2012Accessed: 8688
  
Description

This example saves all attachments of either the opened item or all selected items to the harddisk.

The path assigned to the 'Path' variable must exist yet. The macro automatically creates a subfolder in that directory named with the current date. Eventually the Windows file explorer will be opened with that new directory.

Public Sub SaveAttachments2()
  Dim coll As VBA.Collection
  Dim obj As Object
  Dim Att As Outlook.Attachment
  Dim Sel As Outlook.Selection
  Dim Path$
  Dim i&

  Path = "d:\"
  Path = Path & Format(Date, "yyyy-mm-dd") & "\"
  On Error Resume Next
  MkDir Path
  On Error GoTo 0

  Set coll = New VBA.Collection

  If TypeOf Application.ActiveWindow Is Outlook.Inspector Then
    coll.Add Application.ActiveInspector.CurrentItem
  Else
    Set Sel = Application.ActiveExplorer.Selection
    For i = 1 To Sel.Count
      coll.Add Sel(i)
    Next
  End If

  For Each obj In coll
    For Each Att In obj.Attachments
      Att.SaveAsFile Path & Att.FileName
    Next
  Next

  Shell "Explorer.exe /n, /e, " & Path, vbNormalFocus
End Sub
 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]