NatetheGreat
Active Member
- Joined
- Nov 18, 2013
- Messages
- 268
Hello All,
I have a folder in my outlook entitled "Flippering"
Each email in this folder has an attachment in it. I want to run some Outlook VBA code that will cycle through each email in the folder and save the attachment to a specified path on my local PC.
So far I have set a rule, which runs a script. That script is the following code
When I set the rule to run the script in the flippering folder now, for all messages, it isn't copying anything as I would expect.
Any ideas? I tried to write something that wasn't rule based, i.e. just a macro for ad-hoc extraction, but it failed on
This code failed with "operation could not be found" on the set cfolder line.
I would prefer to have both of these working, the outlook rule based 1st example to continually populate as I receive these emails, and the ad-hoc one to strip everything out when and where needed.
Many Thanks
Nate
I have a folder in my outlook entitled "Flippering"
Each email in this folder has an attachment in it. I want to run some Outlook VBA code that will cycle through each email in the folder and save the attachment to a specified path on my local PC.
So far I have set a rule, which runs a script. That script is the following code
Code:
Sub FlipperExtract(itm As Outlook.MailItem)
Dim objatt As Outlook.Attachment
Dim savefolder As String
Dim dateformat
dateformat = Format(Now, "mmdd H-mm")
savefolder = "C:\Users\me\Desktop\Daily Reports\Flippering"
For Each objatt In itm.Attachments
objatt.SaveAsFile savefolder & "\" & objatt.DisplayName
Set objatt = Nothing
End If
Next
End Sub
When I set the rule to run the script in the flippering folder now, for all messages, it isn't copying anything as I would expect.
Any ideas? I tried to write something that wasn't rule based, i.e. just a macro for ad-hoc extraction, but it failed on
Code:
Sub flipper()
Dim apploutlook As Outlook.Application
Dim nsoutlook As Outlook.NameSpace
Dim atmt As Attachment
Dim cfolder As Outlook.Folder
Set apploutlook = Outlook.Application
Set nsoutlook = apploutlook.GetNamespace("MAPI")
Set cfolder = Outlook.Application.GetNamespace("MAPI").Folders("Flippering")
Destfolder = "C:\Users\me\Desktop\Daily Reports\Flippering"
For Each Item In cfolder
For Each atmt In Item.Attachments
If atmt.FileName = "Flippering.xls" Then
dateformat = Format(Now, "mmdd")
FileName = Destfolder & dateformat & " " & atmt.FileName
atmt.SaveAsFile FileName
i = i + 1
End If
Next atmt
Next Item
End Sub
This code failed with "operation could not be found" on the set cfolder line.
I would prefer to have both of these working, the outlook rule based 1st example to continually populate as I receive these emails, and the ad-hoc one to strip everything out when and where needed.
Many Thanks
Nate