I'm using the following to move a mail to a folder in Outlook.
Dim chemin() as String
chemin = Split(path, "/")
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.Folders("LiveLink").Folders("Livelink HQE").Folders("Entreprise").Folders(chemin(1)).Folders(chemin(2)).Folders(chemin(3))
myEntryID = myFolder.EntryID
myEntryID = myFolder.StoreID
objMail.Move myNameSpace.GetFolderFromID(myEntryID, storeID)
Everything is actually working. As you can see, the folder is located into Livelink. And the Livelink server is actually quite slow to respond, and I can't do anything about it.
My concern is about using the .Folders() so many times while it would be A LOT faster doing something like .Folders("Livelink/root/folder1/folder2/")
. But this isn't working obviously, and because the .Folders command needs to ping the Livelink server everytime, it actually takes a whole 10 seconds just to execute this line of code (and the deeper is the folder, the longer it is to reach it).
Is there any other way to directly access a specific folder in Outlook to move a mail? I know there is some kind of Outlook ID for each folders (even those in Livelink) but I don't see any way to make use of it. I've tried the following, but it's not working yet:
Dim folder As MAPIFolder
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = Application.GetNamespace("MAPI")
Set folder = myNameSpace.GetFolderFromID(target, Application.GetNamespace("MAPI").Folders("LiveLink").storeID)
This gives me an error when doing GetFolderfromID(). The var target
is actually the EntryID of the folder I want to copy the mail to.