Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy attachment error in outlook 2010

Status
Not open for further replies.

Turtleman10

Technical User
Sep 13, 2012
40
US
When I run this code I get the error that I do not have the apropriate permissions. I am the admin on my machine do I need to set something in outlook also?

Code:
Sub CopyAttachments()
 
 ' this is how to save attachments  in temprary folder
 ' objSourceItem = InputBox("SURCE", , , , 8)
  ' objTargetItem = InputBox("TARGET")
    
   Set objApp = CreateObject("Outlook.Application")
   Set objEXP = objApp.ActiveExplorer
   Set objSel = objEXP.Selection
   Set SRC1 = objSel.Item(1)
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
   STRPATH = "C:\test"
   Dim PATH As String
   PATH = "C:\test"
    
  'If Dir(STRPATH & "TMPATCH") = "" Then
  'MkDir STRPATH & "TMPATCH"
  'End If
  'STRPATH = fldTemp.PATH & "\TMPATCH\"
  'Set SRC1 = GetCurrentItem()
    
   For Each ITEM2 In objSel
    
     Set myAttachments = ITEM2.Attachments
         
      If myAttachments.Count > 0 Then
 
          For i = 1 To myAttachments.Count
              myAttachments(i).SaveAsFile PATH & _
              myAttachments(i).DisplayName
          Next
    End If
    Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top