locked
Rule to save attachments to Disk 2013 RRS feed

  • Question

  • Using the Code

    Sub saveAttachtoDisk(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    Dim dateFormat
     saveFolder = "C:\Users\USERNAME\Saved"
     For Each objAtt In itm.Attachments
     objAtt.SaveAsFile saveFolder
     Set objAtt = Nothing
     Next
    End Sub

    I set up a rule to run this script when an email arrice with an attachment

    It runs fine except I get a run time error -247024891 (80070005)' saying cannot save attachment. you don't have appropriate permission to perform this operation.

    can anyone help me with where and what  permissons need to be set

    Tuesday, April 7, 2015 8:30 PM

Answers

  • You need to pass the file name to the SaveAsFile method.

    Sub saveAttachtoDisk(itm As Outlook.MailItem)
     Dim objAtt As Outlook.Attachment
     Dim saveFolder As String
     Dim dateFormat
      saveFolder = "C:\Users\USERNAME\Saved\"
      For Each objAtt In itm.Attachments
      objAtt.SaveAsFile saveFolder & objAtt.DisplayName
      Set objAtt = Nothing
      Next
     End Sub

    Also I'd suggest choosing another drive/folder for saving attachments. For example, try to create a folder on the D: drive and specify that path instead.


    Tuesday, April 7, 2015 8:33 PM

All replies

  • You need to pass the file name to the SaveAsFile method.

    Sub saveAttachtoDisk(itm As Outlook.MailItem)
     Dim objAtt As Outlook.Attachment
     Dim saveFolder As String
     Dim dateFormat
      saveFolder = "C:\Users\USERNAME\Saved\"
      For Each objAtt In itm.Attachments
      objAtt.SaveAsFile saveFolder & objAtt.DisplayName
      Set objAtt = Nothing
      Next
     End Sub

    Also I'd suggest choosing another drive/folder for saving attachments. For example, try to create a folder on the D: drive and specify that path instead.


    Tuesday, April 7, 2015 8:33 PM
  • Awesome Thanks
    Tuesday, April 7, 2015 10:30 PM