I started to create a code to download specific attachments to a disk folder, but i have a Run-time error 424 somewhere in the Set rvItems = rvFolder.Folders("Inbox").Items
Set rvItems = rvFolder.Folders("Test").Items
part. I don't know for what reason and can't figure it out. I am still not declared which exactly attachments i need to be downloaded, but want to see if it works at first place. Can you check it-out and tell me where i'm wrong/missing something, please?
Here's the code :
'ThisOutlookSession part
Private WithEvents rvItems As Outlook.Items
Private Sub Application_Startup()
Dim rvApp As Outlook.Application
Dim rvNS As Outlook.NameSpace
Set rvApp = Outlook.Application
Set rvNS = rvApp.GetNamespace("MAPI")
Set rvInbox = rvNS.GetDefaultFolder(olFolderInbox).Items
Set rvItems = rvFolder.Folders("Inbox").Items
Set rvItems = rvFolder.Folders("Test").Items
End Sub
'Modules part
Private Sub rvItems_ItemAdd(ByVal item As Object)
Dim rvMail As Outlook.mailitem
Dim rvAtt As Outlook.Attachment
If TypeName(item) = "MailItem" Then
Set rvMail = item
For Each rvAtt In rvMail.Attachments
rvAtt.SaveAsFile "C:\Users\BG-TRADE-005\OneDrive - alpiq.com\Desktop\Schedule\Mail_Temp \Download" & rvAtt.FileName
Next rvAtt
Set rvMail = Nothing
End If
End Sub