montecarlo2079
Board Regular
- Joined
- Feb 9, 2011
- Messages
- 207
I have a piece of code that will go to a certain folder and copy all of the attachments into a certain file.
I cant figure out for the life of me how to get it to copy all of these items from my SENT folder.
This code only seems to work from my inbox.
any suggestions?
Sub SaveAttachments()
Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachment
Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
For Each myItem In myFolder.Items
If myItem.Attachments.Count <> 0 Then
For Each myAttachment In myItem.Attachments
myAttachment.SaveAsFile "C:\Users\Desktop\Backups\TEST\" & myAttachment.Filename
Next
End If
Next
End Sub
I cant figure out for the life of me how to get it to copy all of these items from my SENT folder.
This code only seems to work from my inbox.
any suggestions?
Sub SaveAttachments()
Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachment
Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
For Each myItem In myFolder.Items
If myItem.Attachments.Count <> 0 Then
For Each myAttachment In myItem.Attachments
myAttachment.SaveAsFile "C:\Users\Desktop\Backups\TEST\" & myAttachment.Filename
Next
End If
Next
End Sub