Removing Outlook popup box that warns of virus

  • Thread starter Thread starter Todd
  • Start date Start date
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 = "(e-mail address removed)"
.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
 
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 = "(e-mail address removed)"
.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top