Avatar of rogerdjr
rogerdjr
Flag for United States of America asked on

Outlook Office 365 Exchange Server

I had this question after viewing Outlook exchange Office 365 - Add a Subfolder to a "non'Default Folder".

I tried this code to move a folder from my main exchange folder to a subfolder in my archive folder


    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objFolder As Outlook.MAPIFolder
    Dim olParentFolder As Outlook.MAPIFolder
    Dim olMovetoFolder As Outlook.MAPIFolder

    Dim CellValue1 As String, CellValue2 As String, CellValue3 As String
    Dim MoveTo1 As String, MoveTo2 As String
   
    Set objOL = CreateObject("outlook.application")
    Set objNS = objOL.GetNamespace("MAPI")

    CellValue1 = "roger@eaglepromanagement.com"
    CellValue2 = "projects"
    CellValue3 = "TestFolder"
    MoveTo1 = "Online Archive - roger@eaglepromanagement.com"
    MoveTo2 = "projects"

    Set olParentFolder = objNS.Folders(CellValue1).Folders(CellValue2).Folders(CellValue3)
    Set olMovetoFolder = objNS.Folders(MoveTo1).Folders(MoveTo2)
   
    olParentFolder.MoveTo olMovetoFolder
   

It gives me an error message (see attached screenshot)
C--Users-Roger-Downloads-Capture.JPG
OutlookMicrosoft 365Powershell

Avatar of undefined
Last Comment
rogerdjr

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Derek Schauland

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
rogerdjr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Derek Schauland

Glad you got things moving again
rogerdjr

ASKER
I should have thought of permissions - that was the issue.

Thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes