While in design view, go to the code builder and select Tools/References. Check "Microsoft Outlook Object XX Libray". Might as well do the same for DAO 3.6 if that is not checked too. Good luck - it does work.
in code:-
if SaveAttach = false then
' error - no files
endif
Function SaveAttach() As Boolean
Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oTopFldr As Outlook.MAPIFolder
Dim oFldr As Outlook.MAPIFolder
Dim omessage As Object
Dim osubject As String
Dim iCtr As Integer, myFileCt As Integer, myFname As String
Dim iattachCnt As Integer
Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
Set oTopFldr = oNs.GetDefaultFolder(olFolderInbox) ' position to inbox
Set oFldr = oTopFldr.Folders("Pending") ' and sub folder "pending"
SaveAttach = False
myFileCt = 0
For Each omessage In oFldr.Items
With omessage.Attachments
iattachCnt = .Count
If iattachCnt > 0 Then ' at least 1 attachment
osubject = Trim(omessage.Subject)
If Left(osubject, 8) <> "ACardSys" Then ' already detached/processed - optional see below
For iCtr = 1 To iattachCnt
myFname = .Item(iCtr).FileName
.item(iCtr).SaveAsFile myIpPath & myFname
myFileCt = myFileCt + 1
Next iCtr
omessage.Subject = "ACardSys" & Now & osubject ' mark detached on date so don't do again
omessage.Save ' these 2 optional to mark when you've saved the attachment
End If
End If
End With
Next omessage
If myfileCt > 0 Then
SaveAttach = True
Else
MsgBox "No file attachments found", vbCritical, "Process abandoned"
End If
Set omessage = Nothing
Set oFldr = Nothing
Set oNs = Nothing
Set oOutlook = Nothing
End Function