Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Sub MoveDashboardAttachments(Item As Outlook.MailItem) Dim ns As NameSpace Dim Inbox As MAPIFolder Dim Atmt As Attachment Dim SubFolder As MAPIFolder Dim FileName As String Dim olCurrMailItem As MailItem Dim d As Integer Dim intUwv As Integer Dim intWv As Integer Dim i As Integer Set ns = GetNamespace("MAPI") Set Inbox = ns.GetDefaultFolder(olFolderInbox) Set SubFolder = Inbox.Folders("Dashboard_Executive") i = 0 For Each Item In Inbox.Items d = DateDiff("d", CDate(Item.ReceivedTime), CDate(Now())) If d <= 5 Then 'identify which email is being processed by looking at the email-subject intUwv = InStr(1, Item.Subject, "Attachment Test", 1) intWv = InStr(1, Item.Subject, "Attachment Testing", 1) ' if one of the emails is identified then process the email attachments If intUwv + intWv > 0 Then For Each Atmt In Item.Attachments If Right(Atmt.FileName, 3) = "csv" Then FileName = "\\FLFILE01\Warehouse\Data\Jerry\" & Atmt.FileName Atmt.SaveAsFile FileName Item.Move SubFolder i = i + 1 End If Next Atmt intUwv = 0 intWv = 0 End If End If Next Item Set Atmt = Nothing Set Item = Nothing Set ns = Nothing Exit Sub End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.