Pop up error when vba automated email

Shellys28

New Member
Joined
Jun 15, 2015
Messages
12
I have automated some excel sheets to be emailed. However I get the following pop up for every email. How can I automate the "Allow" button in vba script.

***************************************
Microsoft Outlook
A program is trying to send an e-,ail message on your behalf. If this is unexpected, click Deny and verify your antivirus is up-to-date.

For more information about e-mail safety and how you might be able to avoid getting this warning, click Help.

Allow Deny Help (Buttons available in pop up)
*******************************************
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You can try to look for the window and interact with it.

The below looks through the open Windows windows and looks for Internet Explorer in the title. You'd need to rename that to the name of the error window.



Code:
Dim objShellWindows As New SHDocVw.ShellWindows  

  For Each wd In CreateObject("Shell.Application").Windows
    
        If wd = "Windows Internet Explorer" Then
            
           [COLOR=#303336][FONT=inherit]SendKeys [/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"^A"[/FONT][/COLOR]


        End If
            
    Next wd
 
Upvote 0
.
Have you configured OUTLOOK with your email settings (password, address, POP, etc. )?

Also, could you post your macro code for review ?

This is a basic macro for sending email used here :

Code:
Option Explicit


Sub sendemail()
Dim OutlookApp, OlObjects, olMailItem, newmsg


'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)


With newmsg
    'add recipients
    .To = "your email here"
    
    'add subject
    .Subject = "Subject line of auto email here"
    
    'add body
    .Body = "body of auto email here"
    
    .Display 'view message before sending
    
    '.Send 'send message
End With

End Sub
 
Last edited:
Upvote 0
This isn't an error message it's a security message and if you want it to go away you'll probably need to adjust security settings.
 
Upvote 0
This is my current code I am working with. Works exactly as required except for the error security code above. I cannot change my security options, large company with restrictions just want to press Allow button automatically. Pop up box is titled Microsft Outlook with above messages. I am a vba novice & am having trouble even with your codes to get it working.

Sub RunSheet5()

Sheets("TechJobs").Select
Sheets("JobSheet1").Select
ActiveSheet.Copy
ActiveWorkbook.SendMail "Email.Email@xxx.com.au", _
"Job Running Sheet- Johnny"
End Sub
 
Upvote 0
.
You may be able to create a workaround with this resource :

https://www.rondebruin.nl/win/s1/security.htm

Note towards the bottom of the page this :

Or try to use this SendKeys example if you use one of the Outlook object model examples
from my mail page. Instead of .Send in the code examples you can use this three lines.

[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=3]#3[/URL] 366CC].Display
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
[/COLOR]

Note: SendKeys is not always reliable and this will not work on every computer.
The S is from Send, if you not use a English version you must change this letter.
This tip is only working for the Outlook object model examples on my site.

Pay particular notice to his instruction: "Instead of .Send in the code examples you can use this three lines."
Refer to Ron's email examples for sending mail via Outlook. His examples are well referenced and utilized
in the Excel community. The example provided in my post #3 is based on his coding.
 
Upvote 0
I have automated some excel sheets to be emailed. However I get the following pop up for every email. How can I automate the "Allow" button in vba script.

***************************************
Microsoft Outlook
A program is trying to send an e-,ail message on your behalf. If this is unexpected, click Deny and verify your antivirus is up-to-date.

For more information about e-mail safety and how you might be able to avoid getting this warning, click Help.

Allow Deny Help (Buttons available in pop up)
*******************************************



Hello Try the below code:

Sub mymail()
Dim ToAddr As Variant, ccaddr As Variant, ToSubj As String, ToMsg As String



ToAddr = Join(Array("Email_ID_1", " Email_ID_2", " Email_ID_3"), "; ")
ccaddr = Join(Array("Email_ID_1", " Email_ID_2"), "; ")

ToSubj = "SOLS Report -" & Format(Date, "Long Date")

Call Send_Automatic_Email_From_Excel1(ToAddr, ccaddr, ToSubj, ToMsg)
End Sub

Sub Send_Automatic_Email_From_Excel1(ToAddr As Variant, ccaddr As Variant, ToSubj As String, ToMsg As String)

Dim oExcelEmailApp As Object
Set oExcelEmailApp = Outlook.Application.CreateItem(0)

strSignature = Environ("appdata") & _
"\Microsoft\Signatures\Local.htm"

'GET DEFAULT EMAIL SIGNATURE
Signature = Environ("appdata") & "\Microsoft\Signatures"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "*.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll

'Signature = OtlNewMail.HTMLBody
With oExcelEmailApp
.To = ToAddr
.CC = ccaddr
.BCC = ""
.Subject = ToSubj
.HTMLBody = "Hi Team<br>PFA file for today.<br>" & Signature
'<br><p class=MsoNormal><span style='font-size:10.0pt;font-family:Times New Roman,serif;color:#1F497D'>Thanks & Regards,<br><br>" & _
"Your Name<br>Your Designation<br><br> & Signature

.Attachments.Add ThisWorkbook.FullName
.Display
End With

Set oExcelEmailApp = Nothing
End Sub




Kindly Look for the comments in the code and replace with relevant replacements plus have added your email default signatures.Hope It Works :)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top