strFile = _SplitFileName(rstSourceAttachments.Fields(“FileName”))
Debug.Print “File name: “ & strFile
strFileAndPath = strDocsPath & strFile
Debug.Print “File and path: “ & strFileAndPathOn Error Resume NextCheck whether this file already exists in the folder, and save it to the folder if not.Set fil = fso.GetFile(strFileAndPath)
If fil Is Nothing ThenSave this attachment to a file in the Output Docs folder..Fields(“FileData”).SaveToFile strFileAndPath
Debug.Print “Saving “ & strFileAndPath _
& “ to “ & strDocsPath & “ folder”
End IfAdd this attachment to the Attachments collection of the Outlook contact item.Debug.Print “Adding attachment “ & strFileAndPath _
& “ to “ & con.FullName & “ contact”
con.Save
con.Attachments.Add Source:=strFileAndPath, _
Type:=olByValue
con.Close (olSave)
Kill strFileAndPath
.MoveNext
LooprstSourceAttachments.Close
End WithErrorHandlerExit:
Exit SubErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExitEnd SubPublic Sub CopyOutlookAttsToAccess(con _
As Outlook.ContactItem, rstTargetAttachments As _
DAO.Recordset2)Part II Writing VBA Code to Exchange Data between Office Components