Hi All,
My VBA script uses a loop to download attachments from Outlook into a folder on C.
It works well without issues but imports only 8-10 email attachments at a time. I do not get any error in the code and when I click the
Import button on the Access Form, it again imports another 8-10 items.
Not sure why it does limit to 8-10 items rather than go through all the items in WeeklyProceedings Inbox.
There are 30-40 Proceedings daily.
	
	
	
		
TIA
 My VBA script uses a loop to download attachments from Outlook into a folder on C.
It works well without issues but imports only 8-10 email attachments at a time. I do not get any error in the code and when I click the
Import button on the Access Form, it again imports another 8-10 items.
Not sure why it does limit to 8-10 items rather than go through all the items in WeeklyProceedings Inbox.
There are 30-40 Proceedings daily.
		Code:
	
	
	Private Sub cmdOutlook_Click()
'import attachments from WeeklyProceedings Mailbox and saving it in C:\beData\prof_data\Attachments
    Dim olApp As Object
    Dim MYFOLDER As Object
    Dim OlItems As Object
    Dim olMail As Object
    Dim x As Integer
    Dim subject As String
    Dim strFile As String
    Dim strFolderpath As String
    Dim objDestfolder As Object
    Dim mychar As Object
    Dim sreplace As String
    
    DoCmd.OpenForm "frmpleasewait"
    
    DoCmd.SetWarnings False
    
    Set olApp = GetObject(, "Outlook.Application")
    If Err.Number = 429 Then
        Set olApp = CreateObject("Outlook.Application")
    End If
    
    strFolderpath = "C:\beData\prof_data"
    'On Error Resume Next
    
    ' Set the Attachment folder.
    strFolderpath = strFolderpath & "\Attachments\"
    
    Set MYFOLDER = olApp.GetNamespace("MAPI").Folders("WeeklyProceedings Mailbox").Folders("Inbox")
    Set objDestfolder = olApp.GetNamespace("MAPI").Folders("WeeklyProceedings Mailbox").Folders.Item("Folders").Folders.Item("Archive_Proc")
    
    Set OlItems = MYFOLDER.Items
    
    For Each olMail In OlItems
        If olMail.subject Like "*Proceeding ID*" Then
            strFile = olMail & ".XML"
            strFile = strFolderpath & strFile
            If olMail.Attachments.Count > 0 Then
                For x = 1 To olMail.Attachments.Count
                    olMail.Attachments.Item(x).SaveAsFile strFile
                Next x
                
                subject = olMail.subject
                sreplace = "_"
                subject = Replace(subject, " ", sreplace)
                olMail.Body = olMail.Body & vbCrLf & "The file was processed " & Now()
                olMail.subject = "Processed - " & subject
                olMail.Move objDestfolder
                'olMail.Save
            End If
        End If
    Next
 
    Set olMail = Nothing
    Set olApp = Nothing
    
    DoCmd.Close acForm, "frmpleasewait"
    
    MsgBox ("Success")
    DoCmd.SetWarnings True
End SubTIA
 
	 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		