Download Latest email Attachement in Sub Folder
Hi Can anyone help with this please? i have written code for excel to save atachements from a subfolder in MS outlook to a drive however the only issue i seem to be having is applying this to only the last email recieved in the subfolder.
Below is my Code
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim SubFolder As MAPIFolder
Dim MoveToFldr As MAPIFolder
Dim olMi As MailItem
Dim olAtt As Attachment
Dim MyPath As String
Dim i As Long
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
Set SubFolder = Fldr.Folders("Sales Hourly Feed")
Set MoveToFldr = Fldr.Folders("SalesFeed")
MyPath = "C:\Test\"
For i = SubFolder.Items.Count To 1 Step -1
Set olMi = SubFolder.Items(i)
For Each olAtt In olMi.Attachments
olAtt.SaveAsFile MyPath & "SalesFeed.csv"
Set olAtt = Nothing
Set olMi = Nothing
Set Fldr = Nothing
Set MoveToFldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
Thanks in advance for any help.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Search Engine Friendly URLs by vBSEO 3.6.0 RC 1