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:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
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 theFolders
collection that represents all the folders contained in the specified Folder. See Enumerate folders for more information.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.