owentmoore
Technical User
I have an excel file that is to open on a scheduled day every week, perform macro tasks, and close again. If there is an error in doing the tasks, I want the program to email me that there has been an error. The code below creates a new file with the heading "Error with Update Consumables.xls". This is then to be emailed to me. I can then see by the email subject line that there was an issue and investigate.
Problem is when opening the email, outlook recognises that a task is attempting to send an email and asks me I want to allow it or not. I thought by setting "Application.DisplayAlerts = False" this would handle it but it doesn't. How can I get around this alert and get outlook to automatically send the mail?
Problem is when opening the email, outlook recognises that a task is attempting to send an email and asks me I want to allow it or not. I thought by setting "Application.DisplayAlerts = False" this would handle it but it doesn't. How can I get around this alert and get outlook to automatically send the mail?
Code:
ub Send_Email()
Application.DisplayAlerts = False
Workbooks.Add
ActiveWorkbook.SaveAs FileName:= _
"C:\Error with Update Consumables.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.SendMail Recipients:="omoore@dpyie.jnj.com"
ActiveWorkbook.Close
Application.DisplayAlerts = False
End Sub