我试图使用sendkeys绕过outlook alert,这段代码是否正确?

时间:2013-05-14 19:50:10

标签: vba outlook outlook-vba

Sub Mail_Workbook()

Dim wb As Workbook
Set wb = ActiveWorkbook
Application.Wait (Now + TimeValue("0:00:06"))
Application.SendKeys "{TAB}", "false"
Application.SendKeys "{TAB}", "false"
Application.SendKeys "{ENTER}"

If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file that will be removed if you try to send this file." & vbNewLine & _
  "Save the file first as xlsm and then try the macro again.", vbInformation
  Exit Sub
  End If
  End If

On Error Resume Next
   For I = 1 To 3
      wb.SendMail Array("email.person@company.com", "email.person2@company.com"), "Test VBA"
      If Err.Number = 0 Then Exit For
   Next I
On Error GoTo 0
End Sub

1 个答案:

答案 0 :(得分:2)

您需要查看Outlook Redemption:

http://www.dimastr.com/redemption/home.htm

此工具允许您绕过Outlook的安全限制。 以下是产品网站的一些示例代码:

http://www.dimastr.com/redemption/SafeMailItem.htm

有效。