簡體   English   中英

通過 Excel 宏發送 email 時繞過 Outlook 安全

[英]Bypass Outlook Security when sending email via Excel macro

我已經自動提醒從 Excel 發送電子郵件,由 VBS 文件觸發(位於啟動文件夾中)。 當我打開我的電腦時,提醒被觸發,它應該發送 email,但我有一個安全錯誤。

這是 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

我怎樣才能通過在我的宏中添加更多內容來繞過這個錯誤? 錯誤
(我已經嘗試了來自谷歌的所有代碼,但它們都不起作用。我也不想在 Outlook 設置或 Windows 注冊上進行任何更改。)

你有幾個選擇:

  1. 如果您可以控制代碼運行的環境,請安裝最新的防病毒軟件(屆時 Outlook 不會顯示提示)
  2. 擴展 MAPI(C++ 或 Delphi,不適用於 VB 腳本)。 但是,您可以使用像Redemption (我是它的作者)這樣的包裝器,它使用擴展 MAPI,但可以從包括 VBS 在內的任何語言訪問。
  3. ClickYes這樣的產品。

有關討論和可用選項列表,請參閱http://www.outlookcode.com/article.aspx?id=52

更新防病毒安全性后重試。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM