I am using Ron DeBruin's code to automatically send a file via an attachment to an e-mail message as follows:
Sub Mail_workbook_Outlook()
'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I am using Outlook and it is working OK except I am getting a Microsoft Outlook Alert as follows:
A program is automatically trying to send an e-mail on your behalf. Do you want to allow this?
I have tried setting DisplayAlerts to false but it doesn't prevent it. Can anybody tell me how to prevent the alert? Thanks in advance Frank
Sub Mail_workbook_Outlook()
'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I am using Outlook and it is working OK except I am getting a Microsoft Outlook Alert as follows:
A program is automatically trying to send an e-mail on your behalf. Do you want to allow this?
I have tried setting DisplayAlerts to false but it doesn't prevent it. Can anybody tell me how to prevent the alert? Thanks in advance Frank