Removing Outlook popup box that warns of virus

T

Todd

I have written code that will automatically send a
workbook as an attachment in Outlook to a designated
address, however, when it runs Outlook pops up a box that
says "A program is trying to automatically send email on
your behalf...." Is there anyway to keep this from poping
up? The code I have written is below:

Sub Mail_workbook_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = OutApp.CreateItem(0)
End Sub
 
R

Ron de Bruin

Also change the sub to this if you want to use late binding

Sub Mail_workbook_Outlook2()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Top