Mark White
Member
- Outlook version
- Outlook 2013 64 bit
- Email Account
- Exchange Server
Hi
I'm using Outlook 2013 and need to move emails into an archive subdirectory which is fine as per code listed here, but if that subdirectory doesn't exist then my code falls over.
My account has all permissions necessary but in this snippet from code found on this site:
FoldersArray = Split(pstrFolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For intI = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(intI))
If oFolder Is Nothing Then
Application.Session.Folders.Add strNew, olFolder
End If
Next
End If
The line SubFolders.Item(FoldersArray(intI)) falls over if the folder doesn't exist and I can't see how to add something like Application.Session.Folders.Add "NewFolderName"
Any ideas gratefully accepted
Cheers
Mark
I'm using Outlook 2013 and need to move emails into an archive subdirectory which is fine as per code listed here, but if that subdirectory doesn't exist then my code falls over.
My account has all permissions necessary but in this snippet from code found on this site:
FoldersArray = Split(pstrFolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For intI = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(intI))
If oFolder Is Nothing Then
Application.Session.Folders.Add strNew, olFolder
End If
Next
End If
The line SubFolders.Item(FoldersArray(intI)) falls over if the folder doesn't exist and I can't see how to add something like Application.Session.Folders.Add "NewFolderName"
Any ideas gratefully accepted
Cheers
Mark