• Automatically save attachments to hard drive (2002/any)

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Automatically save attachments to hard drive (2002/any)

    • This topic has 3 replies, 3 voices, and was last updated 22 years ago.
    Author
    Topic
    #387929

    I

    Viewing 1 reply thread
    Author
    Replies
    • #678986

      Can’t be done with a Rule. You can write some code or use an attachment management tool such as those listed on Slipstick.

    • #679304

      Sarah,
      I have just been faced with the same problem from a colleague. In the end I wrote a VBA routine to promt for a directory path and then sequentially work through the selected messages, copying the attachments using a filename created from the sender’s name, date/time sent and the attachment filename. This will work on any folder so long as you select the messages first.
      Here is the code if it is of any use:
      Sub attachment_save()
      On Error GoTo Problem
      Dim i, j As Integer
      Dim oSelectedItems As Outlook.Selection
      Dim oMessageItem As Object
      Dim sReport, sFilePath As String
      Set oSelectedItems = ActiveExplorer.Selection

      j = 0 ‘ This is the counter for the number of attachments procesed

      If oSelectedItems.Count = 0 Then
      MsgBox “No Move forms within the view are selected!”, vbCritical, _
      “Attachment Stripper”
      Exit Sub
      End If

      sFilePath = InputBox$(“Enter the directory path. This will be used for ALL the attachments” & _
      ” in the message(s) you have selected.”, “Attachment Stripper”)
      If sFilePath = “” Then
      MsgBox prompt:=”No directory path has been entered”, Buttons:=vbExclamation
      Exit Sub
      End If
      For Each oMessageItem In oSelectedItems
      For i = 1 To oMessageItem.Attachments.Count
      oMessageItem.Attachments.Item(i).SaveAsFile sFilePath & “” & _
      oMessageItem.SenderName & ” ” & _
      FormatDateTime(oMessageItem.ReceivedTime, vbLongDate) & ” ” & _
      Hour(oMessageItem.ReceivedTime) & “-” & _
      Minute(oMessageItem.ReceivedTime) & ” ” & _
      oMessageItem.Attachments.Item(i).FileName
      j = j + 1
      Beep
      Next
      Next

      If i = 1 Then
      sReport = oSelectedItems.Count & ” message containing ” & j & _
      ” attachments have been processed.”
      End If
      If i > 1 Then
      sReport = oSelectedItems.Count & ” messages containing ” & j & _
      ” attachments have been processed.”
      End If

      MsgBox sReport, , “Report”
      GoTo GracefulEnd

      Problem:
      MsgBox prompt:=”There has been a problem.” & vbCrL & _
      “Please check the target directory exists and try again.”, Buttons:=vbExclamation

      GracefulEnd:
      End Sub

      Regards,

      Paul

      • #679374

        You may be interested in a technique provided by JScher2000, which I use in my attachment save routine, to pop the Save Attachment dialog up:

        Dim cbtNSAF As CommandBarButton
        ‘set reference to the Save Attachments dialog
        Set cbtNSAF = ActiveInspector.CommandBars.FindControl(, 3167)
        ‘show the Save Attachments dialog
        cbtNSAF.Execute

        BUT popping the dialog box (in OL 2000) does not return anything, the coder has no way to recognize and handle a cancel or close without save.

        And just for grins, I have attached my custom button for the routine. smile

    Viewing 1 reply thread
    Reply To: Automatically save attachments to hard drive (2002/any)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: