i'm trying to do a PHP/Outlook integration with com_load_typelib("outlook.application");. At the moment, i'm able to send email but is there a way to read some email in a specific folder and put part of content in an excel file?
Now i can count the number of element in my inbox with this code:
$olFolderInbox = 6;
com_load_typelib("Outlook.Application");
echo "Outlook loaded...";
$Outlook = new COM("Outlook.Application") or die("Unable to load Outlook COM");
echo "com object created...";
$OutlookMAPI_Ns = $Outlook->GetNamespace("MAPI") or die("Unable to get Namespace");
echo "namespace created...";
$def_fld_inbox = $OutlookMAPI_Ns->GetDefaultFolder($olFolderInbox) or die("Unable to get olFolderInbox");
echo "got default folder.<br>";
$items_in_folder = $def_fld_inbox->Items->Count();
echo "Items in Inbox: $items_in_folder";
$Outlook->Quit();
echo "Outlook Closed.";
How can i work on a specific SubFolders and parse some information and put part of content in an excel file?
If your code is run on the server-side, Outlook can't be automated from the server-side. Pay attention to the following information:
Read more about that in the Considerations for server-side Automation of Office article.
As a possible workaround you may consider using Graph API (for Office 365) and EWS for Exchange on-premise accounts, see Explore the EWS Managed API, EWS, and web services in Exchange.
Use the Folders property which returns the
Folderscollection that represents all the folders contained in the specified Folder. See Enumerate folders for more information.