Hi
Looking for assistance I have worked out how to reuse code to delete emails from a specified folder within outlook using Excel VBA. The emails are reports scheduled to the folder with attachments of various sizes
For the test I have 6 emails of various sizes 148k, 2mb, 6mb, 634k, 57k, 18mb
The vba code does seem to partially work as it moves the emails to the "deleted items", but only seems to move 3 emails (148k, 2 mb and 6mb) and not the rest, is their a restriction to the size, as a bit puzzled to this.
I would like to eventually permanently delete the emails within the "deleted items", due to the size and save storage space
See code below as it might be useful to another
Public Sub Empty_IT_FileAutomationFolder()
Dim objOwner As Outlook.Recipient 'new
Dim nsSession As Namespace
Dim fldInbox As Outlook.MAPIFolder
Dim fldDBADatabaseInfo As MAPIFolder
Dim olitem As Object
Set nsSession = GetNamespace("MAPI")
Set fldInbox = nsSession.GetDefaultFolder(olFolderInbox)
Set objOwner = nsSession.CreateRecipient("Systems")
objOwner.Resolve
If objOwner.Resolved Then
'MsgBox objOwner.Name
Set fldInbox = nsSession.GetSharedDefaultFolder(objOwner, olFolderInbox)
End If
Set fldDBADatabaseInfo = fldInbox.folders("IT File Automation")
For Each olitem In fldDBADatabaseInfo.Items
olitem.Delete
Next
Set nsSession = Nothing
Set fldInbox = Nothing
Set fldDBADatabaseInfo = Nothing
Set olitem = Nothing
End Sub
Really appreciate the time and assistance
Man chun
Bookmarks