|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
outlook vba - setting reference to subfolder, sometimes no folder items in collection
I'm trying to move an outlook item (email) to a particular subfolder.
This code usually works the first time. But on subsequent times it doesn't... then other times it will, random results. The problem always seems to be getting the subfolders of the Inbox folder... sometimes I get a count of 0 folders in that collection, which is where this will throw up the error "The attempted operation failed. An object could not be found." The commented line below works the same as the three above.... sometimes it works.. sometimes not. Any ideas on what is going wrong?! Code: Code:
Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace("MAPI") Dim oOfficeFolder As Outlook.MAPIFolder Dim oOfficeInboxFolder As Outlook.MAPIFolder Dim oOfficeInboxSupplierFolder As Outlook.MAPIFolder Set oOfficeFolder = NS.Folders.Item("Office") Set oOfficeInboxFolder = oOfficeFolder.Folders.Item("Inbox") Set oOfficeInboxSupplierFolder = oOfficeInboxFolder.Folders.Item("Suppliers") 'Set oOfficeInboxSupplierFolder = NS.Folders("Office").Folders("Inbox").Folders("Suppliers") oMailItem.Move oOfficeInboxSupplierFolder |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Acces a subfolder as main folder over imap in outlook 2010 | Bandit | Outlook | 0 | 10-05-2013 06:23 AM |
Add folder and subfolder to Favorite | ying06 | Outlook | 0 | 03-30-2012 10:41 AM |
Setting a default folder for items to be linked | Thrilling | Outlook | 1 | 03-12-2012 12:09 PM |
How does Outlook decide which Sent Items folder? | rowan.bradley | Outlook | 1 | 02-12-2011 01:43 PM |
Export Subfolder ~ Now ENTIRE Archive Folder is missing? HELP! | TwinCams | Outlook | 0 | 01-31-2011 11:24 AM |