I have manage to add folders in Outlook, but can't work out how to move them. The code I have does not throw out any warnings and does not move the folder:
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
# use existing instance if Outlook is already running, or launch a new one
my $Outlook;
eval {$Outlook = Win32::OLE->GetActiveObject('Outlook.Application')};
die "Outlook not installed" if $@;
unless (defined $Outlook) {
$Outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Outlook";
}
my $namespace = $Outlook->GetNamespace("MAPI");
#my $Folder = $namespace->Folders("backupadmin")->Folders(
# "Inbox")->Folders->Add("test");
my $Folder = $namespace->Folders("backupadmin")->Folders(
"Inbox")->Folders("test")->MoveTo("test1");
...->Folders("test")->Name = "test1"
may work (or something similar using proper syntax likesetName
, etc.). Renaming reference – abiessumy $Folder = $namespace->Folders("backupadmin")->Folders("Inbox")->Folders("test")->{"Name"} = "test1";
(again assuming that the intent is to rename the folder, not re-parent it), or...->Folders("test")->SetProperty('Name', "test1")
– abiessu