[Outlook]如何规避“Email Security Update”警告框

来源:互联网 发布:社交网络电影完整版 编辑:程序博客网 时间:2024/05/22 03:50

 

如何规避“Email Security Update”警告框?

编写者:郑昀(转载时请注明)

在各种版本的Outlook安装了“Email Security Update”补丁之后,每当我们访问某些字段时,都会弹出警告框。但是Outlook 2003除外,Outlook 2003 在以下三种类型应用程序访问时不弹出警告框:

?         VBScript code in published, non-oneoff Outlook forms

?         Outlook VBA code that uses the intrinsic Application object

?         Outlook COM add-ins properly constructed to derive all objects from the Application object passed by the OnConnection event

在很多操作Outlook事件中,我们都需要访问敏感字段,我们可以这样来规避警告框:

我们先在本地硬盘新建一个临时的VBScript脚本文件;另外启动一个Wscript.Exe引擎,运行事先写好的VBScript脚本。它不断检测当前激活的窗口,如果出现了那个警告框,就用SendKeys的方法选中“a”和“y”按键,从而允许一分钟之内可以访问敏感字段。这样,虽然警告框仍然会弹出,但是用户几乎不会注意到它,也不会增加用户的操作复杂度。

由于Outlook XP版本中的该警告框并没有给“Yes”按钮设置y热键,所以我们这时候必须再次发送两个TAB和一个ENTER键消息,才能够关闭该警告框。

所运行的VBScript脚本内容如下所示:

Set fso = CreateObject("WScript.Shell")

While fso.AppActivate("Microsoft Outlook") = FALSE

       wscript.sleep 50

Wend

fso.SendKeys "a", True

fso.SendKeys "y", True

fso.SendKeys "{TAB}{TAB}{ENTER}", True

 

 

在“g_oApplication_ItemSend”和“g_oNewMailSMS_Click”事件中,我们是这么做的:

首先,检查Outlook版本,如果是2003版本以下,那么我们调用Scripting.FileSystemObject对象,创建一个名为“ByPass.vbs”的文件,默认在当前Outlook应用程序路径下。文件内容就是上面的VBScript脚本内容。对于Outlook 2003,我们不用理会。

其次,调用

Set wshShell = CreateObject("Wscript.Shell")

wshShell.Run ("wscript.exe ByPass.vbs //B")

来运行这个脚本。

最后,当事件完成,就把这个脚本删除。

 

Writen by zhengyun.nojunk(at)gmail.com

附录:

    On Error Resume Next
    Dim strOutlookVersion As String
    Dim fso, wshShell
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim strFileNameOfByPass As String ' VBScript脚本文件名
    strFileNameOfByPass = "OutlookEmailSecurityUpdateByPass.vbs"

    strOutlookVersion = g_oApplication.Version
    Dim arraySplit
    arraySplit = Split(strOutlookVersion, ".")
    strOutlookVersion = arraySplit(0)
    ' 检查Outlook版本号:
    Dim fsoFile
    If CInt(strOutlookVersion) < 11 Then
   
        ' 先创建一个VBScript脚本文件
        Set fsoFile = fso.CreateTextFile(strFileNameOfByPass)
        fsoFile.WriteLine "Set fso =CreateObject(""WScript.Shell"")"
        fsoFile.WriteLine "While fso.AppActivate(""Microsoft Outlook"") = FALSE"
        fsoFile.WriteLine "wscript.sleep 50"
        fsoFile.WriteLine "Wend"
       
        If CInt(strOutlookVersion) = 9 Then
            ' Outlook2000默认按钮上有快捷键设置,所以可以发射a和y键即可:
            fsoFile.WriteLine "fso.SendKeys ""a"", True"
            fsoFile.WriteLine "fso.SendKeys ""y"", True"
        End If
       
        If CInt(strOutlookVersion) = 10 Then
            '
            ' 在OutlookXP上面,这个警告框的“Yes”按钮并没有设置y热键
            ' 所以我们发送y键没有用,那么我们继续发送两个TAB和一个回车
            ' 也可以起到关闭警告框的作用
            fsoFile.WriteLine "fso.SendKeys ""a"", True"
            fsoFile.WriteLine "fso.SendKeys ""{TAB}{TAB}{ENTER}"", True"
        End If
       
        fsoFile.Close
       
        ' 然后运行它:
        If fso.FileExists(strFileNameOfByPass) Then
            Set wshShell = CreateObject("Wscript.Shell")
            wshShell.Run ("wscript.exe " & strFileNameOfByPass & " //B") '//B代表不要弹出错误对话框
        End If
    End If
    On Error GoTo 0



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=33826


原创粉丝点击