首页 文章

通过Excel宏发送电子邮件时绕过Outlook安全性

提问于
浏览
1

我已经做了一个自动提醒,从Excel发送电子邮件,由VBS文件(放在StartUp文件夹中)触发 . 当我打开我的电脑时,触发提醒,它应该发送电子邮件,但我有一个安全错误 .

这是Excel宏:

Sub Email()
Dim aOutlook As Object
Dim aEmail As Object
Dim i As Integer
For i = 1 To 100      
If Cells(i, 3).Value = Date And IsEmpty(Cells(i, 7)) Then  
        Set aOutlook = CreateObject("Outlook.Application") 
        Set aEmail = aOutlook.CreateItem(0)
        aEmail.Importance = 2
        aEmail.Subject = ActiveSheet.Cells(i, 4)
        aEmail.Body = ActiveSheet.Cells(i, 5)
        aEmail.To = ActiveSheet.Cells(i, 6)
        aEmail.Send
        Cells(i, 7).Value = "Sent: " & Now
End If
Next i
End Sub

这是VBS文件:

Dim xlApp, xlBook
Set wshShell = CreateObject( "WScript.Shell" )
Set xlApp = CreateObject("Excel.Application") 
userName = wshShell.ExpandEnvironmentStrings( "%UserName%" )
Set xlBook = xlApp.Workbooks.Open("C:\Users\" + userName + "\Desktop\RM.xlsm", 0, False) 
xlApp.Application.Run "Email"
xlBook.Save
xlBook.Close
xlApp.Quit 
Set xlApp = Nothing
Set xlBook = Nothing

How can I can bypass this error, by adding something more in my macro?
error

(我've tried all the codes from google, but none of them work. I also don' t想要在Outlook设置或Windows Reg上不做任何改动 . )

2 回答

  • 0

    你有几个选择:

    • 安装最新的防病毒软件(如果您可以控制运行代码的环境,则Outlook不会显示提示)

    • 扩展MAPI(C或Delphi,不适用于VB脚本) . 但是,您可以使用像Redemption这样的包装器,它使用扩展MAPI,但可以从任何语言(包括VBS)访问 .

    • ClickYes这样的产品 .

    有关讨论和可用选项列表,请参阅http://www.outlookcode.com/article.aspx?id=52 .

  • 1

    更新防病毒安全性后再试一次 .

    enter image description here

相关问题