I created this VBA code which works on the emails with attachments coming into the inbox.
how can I change it to look at a folder called lunches?
I have code to get lunches flde rbut don't know how to modify the
DougP
< I Built one
how can I change it to look at a folder called lunches?
I have code to get lunches flde rbut don't know how to modify the
Code:
Sub GetAttachments()
On Error GoTo GetAttachments_Error:
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders("lunches")
i = 0
For Each Item In Inbox.Items ' change this to look at lunches folder
For Each Atmt In Item.Attachments
' if excel save it and add email name to it
Debug.Print Atmt.FileName
If Right(Atmt.FileName, 3) = "xls" Then FileName = "S:\IT\aaa Email Attachments\" & Item.SenderEmailAddress & "|" & Atmt.FileName
Atmt.SaveAsFile FileName
End If
i = i + 1
Next Atmt
Next Item
MsgBox "All Excel Sheets saved", vbInformation, "Finished Saving..."
GetAttachments_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub
GetAttachments_Error:
Select Case Err.Number
Case Else
MsgBox Err.Number & Err.Description, vbExclamation, "Error in sub GetAttachments"
Resume 'GetAttachments_exit
End Select
End Sub
DougP
< I Built one