php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

Delete a folder

Open r-hede opened this issue 7 years ago • 4 comments

Hi,

I am trying to delete a folder with the following code:

use garethp\ews\API\Enumeration\DistinguishedFolderIdNameType;

$api = MailAPI::withUsernameAndPassword($host, $login, $password);

$folders = $api->getChildrenFolders(DistinguishedFolderIdNameType::MESSAGE_ROOT);

$api->deleteFolder($folders[$folderId]->getFolderId());

It seems simple but it doesn't work.

Of course, the folderId variable is the location of the folder that I created and that I want to delete.

Could you help me?

Thank you.

r-hede avatar Feb 28 '18 16:02 r-hede

What's the error that you're getting?

Garethp avatar Mar 01 '18 15:03 Garethp

Just a simple error 500, no error message is displayed.

r-hede avatar Mar 01 '18 16:03 r-hede

There should almost definitely be an exception of some kind. What about a stack trace?

Garethp avatar Mar 01 '18 16:03 Garethp

Effectively, I activated PHP errors and I get this:

Fatal error:  Uncaught Error: Call to undefined function garethp\ews\garethp\ews\Utilities\getFolderIds() in C:\Apache24\htdocs\new-app-v4\app\library\garethp\php-ews\src\API.php:227
Stack trace:
#0 C:\Apache24\htdocs\new-app-v4\app\library\garethp\php-ews\src\API.php(222): garethp\ews\API->deleteFolders(Object(garethp\ews\API\Type\FolderIdType), Array)
#1 C:\Apache24\htdocs\new-app-v4\app\controllers\MailBoxController.php(66): garethp\ews\API->deleteFolder(Object(garethp\ews\API\Type\FolderIdType))
#2 [internal function]: MailBoxController->indexAction()
#3 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(MailBoxController), 'indexAction', Array)
#4 [internal function]: Phalcon\Dispatcher->dispatch()
#5 C:\Apache24\htdocs\new-app-v4\public\index.php(36): Phalcon\Mvc\Application->handle()
#6 {main}
  thrown in C:\Apache24\htdocs\new-app-v4\app\library\garethp\php-ews\src\API.php on line 227

However the function getFolderIds is correctly defined.

I specify that I use the latest version (0.9.6 - TBD).

r-hede avatar Mar 02 '18 08:03 r-hede