【问题标题】:Get rid of warning message for VBA-sent email摆脱 VBA 发送电子邮件的警告消息
【发布时间】:2018-06-21 07:53:44
【问题描述】:

我在 Access 数据库中内置了一个警报发送辅助工具,它可以一次性向所有具有过期/ing 感应的技术人员发送电子邮件。每封电子邮件都需要发送权限。


类似于this questionthis question,但我需要同时自动发送多封电子邮件,而不会阻碍其他进程。
问题中的代码似乎发送了一封电子邮件,唯一被接受的答案是等待 5 秒最多 3 次以检查实际消息是否已显示,以便 SendKeys 可以在该窗口上工作。

如果我使用 SendKeys 并内置 5 秒的暂停来等待确认 as Graham Anderson suggests,这不会加快进程,只能避免一些点击。警告(下)上显示的进度条大约需要那个时间来填充,所以我猜这是构建电子邮件的系统,这就是等待的原因。

同样的问题适用于 Julia's answer 的另一个问题 - 在进度条已满之前,警告框不会让您点击“允许”,因此自动点击此按钮的代码最多只能等待完成.

我尝试了DoCmd.SetWarnings (False)(然后在发送后尝试了DoCmd.SetWarnings (True)),但这并没有阻止这个特定的。这可能是因为警告来自 Outlook 而不是 Access。


我的编码:

Private Sub SendAlerts_Click()
    Dim db As Database, rs As Recordset
    Dim Subject As String, Body As String, EmailAddress As String
    Dim Recipient As String, Induction As String, Expiry As String
    Set db = CurrentDb
    Set rs = db.OpenRecordset("qryExpiryAlert", dbOpenDynaset)

    Do Until rs.EOF
        EmailAddress = rs!Email
        Recipient = rs!FullName
        Induction = rs!Induction
        Expiry = rs!ExpiryDate
        Subject = "Inductions need renewal"
        Body = "Hi " & Recipient & ", the expiry for your " & Induction & _
            " certificate is " & Expiry & ". Please send a current certificate asap."

        DoCmd.SendObject , , , EmailAddress, , , Subject, Body, False
        
        rs.MoveNext
    Loop
    
    DoCmd.Close
    
End Sub

这里是警告:

【问题讨论】:

  • @Andre - 我检查了 - 问题是“防病毒状态:不可用。此版本的 Windows 不支持防病毒检测。”而且 IT 不会授予我更改程序访问选项的管理员权限。
  • 如果您的 IT 无法让 Outlook 正常运行,您将需要一个 SMTP 服务器来发送电子邮件,例如使用blat.net——顺便说一句,您应该添加您使用的 Outlook/Office 版本。
  • 请参阅outlookcode.com/article.aspx?id=52 了解您的选项列表。

标签: ms-access outlook vba warnings


【解决方案1】:

我编写并编译了一个 Autohotkey 脚本,它查找 Outlook 确认对话框并自动单击允许。 (我从 Access VBA 调用它,并且可以设置它在关闭之前运行多长时间。)不过,正如您所指出的,等待每次启用“允许”按钮仍有相当长的延迟。

最终,我们公司最终购买了Outlook Security Manager。像往常一样,您必须为您的项目添加一个Outlook Security Manager Reference. 引用。

它基本上有 ON 和 OFF 设​​置,所以很容易使用。如果在标准模块中写一个 Sub 来简化:

Public Sub SetSecurityManager(State As String)
    ' Turns the Security Manager on or off.
    ' The Security Manager allows the application to
    ' send emails through Outlook without having to
    ' manually confirm each outgoing email.

    Select Case State
        Case "On"
            ' Temporarily turn off Outlook security so we can send email
            Set SecurityManager = CreateObject("AddInExpress.OutlookSecurityManager")
            SecurityManager.DisableOOMWarnings = True
            SecurityManager.DisableSMAPIWarnings = True
        Case "Off"
            'Restore Outlook security to normal
            SecurityManager.DisableSMAPIWarnings = False
            SecurityManager.DisableOOMWarnings = False
            Set SecurityManager = Nothing
        Case Else
    End Select

End Sub

每当我需要它时,我都会将此行添加到我的代码中:

SetSecurityManager "On"

不得不为我们购买的软件造成的安全问题付费解决方案令人沮丧,但这是我们找到的最佳解决方案。我每天发送 150 到 225 份报告,并且对 OSM 没有任何问题。

谢谢,

基思

【讨论】:

  • 上面提到的产品以及this one 是我正在考虑的选项,尽管刚刚发现我们可能很快就会改变 Windows 系统......所以这里希望会有一个绕过它。
猜你喜欢
  • 2018-03-07
  • 1970-01-01
  • 2021-04-06
  • 1970-01-01
  • 2021-09-21
  • 2018-09-04
  • 1970-01-01
  • 2021-10-25
  • 1970-01-01
相关资源
最近更新 更多