删除 VBA 已发送电子邮件的警告消息
Get rid of warning message for VBA-sent email
我有一个内置于 Access 数据库中的警报发送辅助工具,可以通过 expired/ing 感应向所有技术人员一次性发送电子邮件。每封电子邮件都需要发送权限。
与 this question and this question 类似,但我需要同时自动发送多封电子邮件,而不会阻止其他进程。
问题中的代码似乎只发送一封电子邮件,唯一接受的答案涉及等待五秒钟最多三次以检查是否已显示实际消息,以便 SendKeys
可以处理 window .
如果我使用 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
这是警告:
我编写并编译了一个 Autohotkey 脚本,用于查找 Outlook 确认对话框并自动单击“允许”。 (我从 Access VBA 调用它,并且可以设置它 运行 在关闭之前持续多长时间。)但是,正如您所指出的,等待启用“允许”按钮仍然有相当长的延迟每次。
最终,我们公司购买了 Outlook Security Manager. As usual, you have to add an Outlook Security Manager Reference. 参考您的项目。
它基本上有开和关设置,所以很容易使用。如果在标准模块中写一个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 没有问题。
谢谢,
基思
我有一个内置于 Access 数据库中的警报发送辅助工具,可以通过 expired/ing 感应向所有技术人员一次性发送电子邮件。每封电子邮件都需要发送权限。
与 this question and this question 类似,但我需要同时自动发送多封电子邮件,而不会阻止其他进程。
问题中的代码似乎只发送一封电子邮件,唯一接受的答案涉及等待五秒钟最多三次以检查是否已显示实际消息,以便 SendKeys
可以处理 window .
如果我使用 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
这是警告:
我编写并编译了一个 Autohotkey 脚本,用于查找 Outlook 确认对话框并自动单击“允许”。 (我从 Access VBA 调用它,并且可以设置它 运行 在关闭之前持续多长时间。)但是,正如您所指出的,等待启用“允许”按钮仍然有相当长的延迟每次。
最终,我们公司购买了 Outlook Security Manager. As usual, you have to add an Outlook Security Manager Reference. 参考您的项目。
它基本上有开和关设置,所以很容易使用。如果在标准模块中写一个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 没有问题。
谢谢,
基思