- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这样的情况:
我认为无法以自动化的方式使用 Outlook 发送电子邮件(在以屏幕锁定的用户身份登录的无人值守的盒子上)。我尝试了许多不同的方法,但总是收到安全警告消息。我该如何解决这个问题?
我已经尝试了 this 上的所有内容有用的网站并删除了每个选项,如下所示:
Strategies
Ideally, applications that automate Outlook should avoid code that triggers these security prompts.
这正是我最终所做的(请参阅下面的答案),这就是为什么该页面上的所有其他选项都不相关的原因。让我们一一来看:
Sending messages
It is not necessary to use Outlook objects at all if your goal is simply to create and send an email message. Microsoft provides the CDO for Windows library for creating and sending messages with SMTP. Using this library totally bypasses Outlook and MAPI and does not trigger security prompts. For code samples, see ...
SMTP。不许去。网络策略不允许。
Use Extended MAPI instead of Outlook objects, Simple MAPI, or CDO 1.21 for all code that potentially triggers security prompts.
扩展 MAPI 可能有效,但它非常麻烦和冗长,并且涉及大量 C/C++ 代码(这不是这个问题的主题;见上文),并且似乎不可能在不提示用户的情况下使用它他们的密码。
Use a third-party library -- Redemption or MAPI33 -- for all code that potentially triggers security prompts. This approach is easier than using Extended MAPI, which has a steep learning curve, and almost as secure. These libraries also offer additional features to help with Outlook code projects.
第三方库的问题有四个方面: - 它们需要花钱; - 即使它们是免费的,它们也会引入许可问题(一些组织在允许软件进入生态系统之前需要经过律师的广泛审查); - 在大多数环境中,用户无法禁用 Outlook 选项中的编程访问警告,甚至会引发整个问题。嗯,那些可能的情况是什么?难道是……公司环境?在企业环境中采购软件需要花费太长的时间,以至于不切实际,除非使用它节省的成本超过数百万美元。但是,可以进行许多实际的流程改进,这些改进不会带来很高的成本节省,但如果需要软件采购,则采购第三方软件所花费的金钱和劳动力会比节省的总成本更多。 - 网络管理员可能不信任该软件驻留在系统上,因为它可能被用于恶意目的。
Deploy with your application a tool to suppress the security prompts.
这假设有必要抑制 OMG 提示,但就我而言,并非如此,只是为了发送一封简单的电子邮件(请参阅我的答案)。
For Outlook 2007, make sure the machine is running an up-to-date anti-virus application and do all coding with Outlook objects, avoiding CDO 1.21 and Simple MAPI code.
病毒扫描程序是最新的,但更改其版本或供应商完全超出我的控制范围,而且 Outlook 无法识别它。它显示:“防病毒状态:无效。此版本的 Windows 支持防病毒检测,但未找到防病毒。”
In Outlook custom form code, Outlook VBA code, and COM add-ins, derive all objects from the Outlook.Application object provided by VBA or the add-in architecture. For example, see the sample VBA "run a script" rule procedure below.
有趣,可能有用,但不是必需的。这会不必要地依赖于在 Outlook 中设置规则来部署软件,从而使部署变得复杂。
Deploy Outlook security settings that "trust" certain COM add-ins or that allow all applications to have unrestricted access to certain features, such as accessing addresses. In versions before Outlook 2007, this requires Microsoft Exchange Server. For Outlook 2007, see the section on version-specific considerations below.
麻烦:安装 COM 加载项需要管理访问权限,而在某些组织中可能很难获得管理访问权限。
In a corporate environment where Exchange is the email server, direct access to the data on the server is available through the WebDAV API beginning with Exchange 2000 and, starting with Exchange 2007, through Exchange Web Services.
在我的环境以及其他可能的环境中被禁用。
In a corporate environment, the administrator may choose to loosen Outlook security for some or all users.
当然,但这需要与网络团队沟通/协调/合作。如果管理访问权限不可用于安装 COM 插件,那么它也可能不可用于放松组策略。
最佳答案
此代码适用于我的 Outlook 2010 系统,无需用户交互即可发送电子邮件。它有点脆弱,因为如果用户在撰写邮件时恰好在系统上积极工作(打字、单击),则可能会出现用户输入进入弹出窗口的情况瞬间,要么干扰邮件的发送,要么在邮件正文中添加额外的未知字符。
只要运行此功能的系统的用户意识到这一点,并且虚假击键干扰的潜在后果不是业务关键型,则此功能是可以接受的。
需要注意的是:此解决方案的关键是我们不调用 MailItem.Send
方法。这是触发编程访问保护的方法。相反,我们触发 ALT+s 快捷方式,默认情况下,当邮件窗口在 Outlook 中获得焦点时,会按下“发送”按钮。如果您启用了默认的拼写检查提示,则会弹出进一步的拼写检查提示。我们的解决方案是禁用拼写检查提示,尽管我确信您可以添加更多 SendKeys 来单击它,因为拼写检查提示不是与安全相关的对话框。
关于 UIPI(用户界面权限隔离)的说明:
Outlook 2010 以登录系统的用户身份运行,完整性级别为中。由 Windows 资源管理器启动的程序,或者作为以类似方式启动的程序的子程序或后代启动的程序,也将以中完整性级别启动。只要用户和 session ID 匹配,并且完整性级别相同或更高,UIPI 就不能有效阻止“SendKeys”类型输入。在我的特定环境中,VBScript 主机进程和 Outlook 进程的用户和 session ID 相同,完整性级别相同。在您的环境中,如果其中任何条件不成立,则此代码将无法工作。它也未在 2010 版之前或更高版本的 Office 上进行测试。
Sub SendEmail_Outlook()
Set WshShell = WScript.CreateObject("WScript.Shell")
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to= "you@example.com"
Mail.Subject = "test"
Mail.HTMLBody = "test"
Mail.Display
WshShell.SendKeys "%s"
Set Mail = Nothing
Set ol = Nothing
End Sub
SendEmail_Outlook
此外,还介绍了如何在从 Windows 任务计划程序运行 VBScript 时实现此功能。只需勾选红色椭圆形“以最高权限运行”框,即可使其以尽可能高的完整性级别运行,而无需 UAC 提升(如果您不是管理员帐户,则为“中”)。
关于vbscript - 从 VBScript 发送 Outlook 邮件时如何避免 Outlook 安全警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14898756/
我正在使用下面的脚本来调用另一个脚本。问题是我必须将 WScript.Arguments 检索到的参数传递给我正在调用的第二个脚本。有人可以告诉我该怎么做吗。 Dim objShell Set obj
我正在使用下面的脚本来调用另一个脚本。问题是我必须将我通过 WScript.Arguments 检索的参数传递给我正在调用的第二个脚本。有人可以告诉我该怎么做吗。 Dim objShell Set o
我有一个非常简单的 vbscript 代码: Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.Prog
我需要将名称基于日期的文件移动到另一个文件夹。 文件结构为: 来源: \\network_location\folder\Filename_09-11-2012.txt 目的地: C:\Dump\Fi
我有一个关于 VBScript 中变量作用域的问题。我知道有以下关键字(来自 autoitscript.com ): Dim = 局部作用域,如果变量名在全局不存在(在这种情况下它重用全局变量!) G
我正在尝试在 VBScript 中运行以下代码但它没有编译最后一条语句。是不是因为VBScript不允许命名参数? Filename_Argument = WScript.Arguments(0) S
在VBScript中,我需要确保用户输入一个整数。 这是我现在所拥有的: WScript.Echo "Enter an integer number : " Number = WScript.StdI
使用这些信息,我学会了here和here。 我在下面创建了短代码。 当我运行代码并有意识地输入任务计划程序库的“\”文件夹中存在的任务时,我收到“任务不存在” msgbox。 我尝试在传递给函数的变量
我试图仅用VBScript编写一个小的脚本供家庭使用,该脚本在Macrium Reflect中进行预定备份之前运行。 我被困在一个看似很小的问题上,这是在物理断开网络驱动器(即未连接电缆)时的错误处理
我阅读了 Eric Lippert 关于 VBScript 中默认属性语义的文章:http://blogs.msdn.com/b/ericlippert/archive/2005/08/30/4580
我正在尝试使用 VBScript 过滤二维数组,但 VBScript 的内置“过滤器”函数仅适用于单维数组。我使用的是“rs.GetRows()”数组,那么是否有一个可以处理二维数组的简单函数? 编辑
尝试在 HP-UFT 中运行时,下面的 VBScript 代码让我感到困惑,因为第一个语句打印 True 而不是 False (这似乎不合逻辑),而第二个打印 False (这似乎合乎逻辑) 代码:
我刚刚了解到 $ 需要转义字符。 VBScript 中还有哪些特殊字符? 还有一个 bool 函数可以用来判断一个字符是否是特殊字符? 最佳答案 嗯? WScript.Echo "$" 输出 $ 而不
我需要将批处理文件转换为 vbscript,但我对两者都不熟悉。如果我能理解批处理文件中发生的事情,我就可以很容易地计算出 vbscript。问题是批处理文件运行一些 cscript 命令,其语法应该
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
长期以来,人们一直在批处理文件中嵌入和执行 VBScript。但是我看到的所有已发布的解决方案(在最初提出这个问题时)都涉及编写临时 VBS 文件。例如:Embed VBScript inside W
如何检查文件夹中是否存在任意名称的文件?我还想忽略子文件夹。 谢谢。 编辑: 我想我已经明白了,但也感谢任何贡献...... If Folder.Files.Count > 0 Then 'Do
我对编程很陌生,我想制作一个程序,从 Vb 脚本的列表中随机选择一个名称或句子。 这是列表: Jacob James Jason Caleb Ashlee John 程序需要从该列表中选择一个随机名称
如何检查文件夹中是否存在任意名称的文件?我还想忽略子文件夹。 谢谢。 编辑: 我想我已经明白了,但也感谢任何贡献...... If Folder.Files.Count > 0 Then 'Do
我需要一个 Vbscript,它可以从我的 PC 打开一个图像文件,并在几分钟后自动关闭。我计划通过命令提示符运行脚本,非常感谢任何帮助。 最佳答案 使用 HTML Application 可能更容易
我是一名优秀的程序员,十分优秀!