Runing VBScript code for Outlook through a scheduler

夙愿已清 提交于 2019-12-25 09:02:04

问题


I have written a VBScript for Outlook that forwards email which are lying unread in the inbox for more than 30 minutes. When I manually run the vbs file it works perfectly fine, but when I trigger is through Windows Task Scheduler it gets stuck. Seems like it does not hit the Outlook and stops executing at the CreateObject(...) statement.

Could you please let me know how should I go about. I want to schedule it to run the script over Outlook every 30 min.


回答1:


When I manually run the vbs file it works perfectly fine, but when I trigger is through Windows Task Scheduler it gets stuck.

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 workaround you may consider using EWS if you deal with Exchange profiles only, see EWS Managed API, EWS, and web services in Exchange. Or Outlook REST API which is available for Office 365 users, see Get Started with Mail, Calendar, and Contacts REST APIs.

Also you may consider using a low-level API on which Outlook is based on - Extended MAPI. Or just any other third-party wrapper around that API such as Redemption.



来源:https://stackoverflow.com/questions/43435188/runing-vbscript-code-for-outlook-through-a-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!