【发布时间】:2014-01-28 08:58:32
【问题描述】:
我正在使用 Ron de Bruin 网站上的代码使用 Outlook 通过 Excel 发送电子邮件。我收到此安全警告“程序正在尝试代表您发送电子邮件”,要求我允许或拒绝。
如何避免此警告并直接发送电子邮件"
注意:我使用的是 Excel 2007。
代码如下:
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim cell As Range
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Sheets("" & Sheet & "").Select
With Sheets("" & Sheet & "")
strbody = ""
End With
On Error Resume Next
With OutMail
.To = " email1@a.com"
.CC = ""
.BCC = ""
.Subject = ""
.Body = strbody
.From = ""
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
' restore default application behavior
Application.AlertBeforeOverwriting = True
Application.DisplayAlerts = True
ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True
【问题讨论】:
-
查看类似问题的答案here
标签: vba excel outlook excel-2007