Send Email Through Python Using Outlook 2016 Without Opening It
Solution 1:
You need to use Outlook REST API without automating Outlook. Take a look at the following samples:
Be aware, 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.
Solution 2:
The problem is that message submission is asynchronous, and your code exits before the message is sent. In case of Exchange, try to turn off the cached mode - online store will send the message immediately. Otherwise (cached Exchange or PST store), you need to hold to the Outlook object until the message is actually submitted. You need to wait for the SyncObject.SyncEnd
event to fire. SyncObject
can be retrieved from the Namespace.SyncObjects
collection ("All Accounts" is the first item in that collection).
Post a Comment for "Send Email Through Python Using Outlook 2016 Without Opening It"