MS Access VBA to Outlook - This SHOULD work?
Its very strange...
I had 2 subfolders of Skipped created (Unknown and Duplicates) and was trying to set a variable to the "Unknown" folder.
it keeps erroring saying an object could not be found. SO i did the following code to test
Code:
Set OTL = New Outlook.Application
Set ONS = OTL.GetNamespace("MAPI")
Set LCDf = ONS.Folders("LCDisputeDB")
Set INBX = ONS.Folders("LCDisputeDB").Folders("Inbox")
Set SKIPD = ONS.Folders("LCDisputeDB").Folders("Skipped")
Set UNK = LCDf.Folders("Skipped").Folders.Add("Unknown")
Debug.Print SKIPD = UNK.Parent.Name 'True
Debug.Print SKIPD.FolderPath '\\LCDisputeDB\Skipped
Debug.Print UNK.FolderPath '\\LCDisputeDB\Skipped\Unknown
Set UNK2 = SKIPD.Folders("Unknown")
Set UNK works as you can see the debug results...
But when I set a variable to the Unknown it says its not there?
I can also do
Debug.Print SKIPD.folders.Count and get 0 ???
also tried
Set UNK2 = ONS.Folders("LCDisputeDB").Folders("Skipped").Folders("Unknown")
it cant see it!?? but yet UNK is created...
Re: MS Access VBA to Outlook - This SHOULD work?
i made a similar test, works correctly for me
where test existed under inbox
Code:
Set inb = GetNamespace("mapi").GetDefaultFolder(olFolderInbox)
Set nw = inb.Folders("test").Folders.Add("mytest")
Set tst = nw
Set test2 = inb.Folders("test").Folders("mytest")
all object variables were correctly assigned
Re: MS Access VBA to Outlook - This SHOULD work?
It is probably just your hierarchy of folder structures is off. Everything is under the Inbox so you would need to drill down through it to get to a subfolder.
These are not Public Exchange folders right?
The double slashes are a different pst file? If so you have to connect to them just like you change connections in sql to different databases