Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate clicking a button in a popup window 1

Status
Not open for further replies.

Sparky1157

Programmer
Aug 19, 2016
30
US
I created a macro to automate sending out an email using Microsoft Outlook. In the email I wish to include an image which I’ve placed in Sheet2 in the range A1:F25. However, when I want to paste this image into the body of the email, I receive the following popup message:

Windows_Outlook_cenyao.jpg


In an attempt to automate “clicking” on the ALLOW button, I’ve established steps in order to find that window and identify that button to click on. However, my attempt isn’t working, and I would like some assistance in correcting the situation.

Thank you in advance for your support and assistance!

The attached file has my coding attempt....
 
 https://files.engineering.com/getfile.aspx?folder=3785827c-e97d-4450-9e7f-2d07754f593a&file=OLD_404_APPLY.txt
Let me posit a querstion; imagine a virus had got onto your machine and was trying to spread by sending emails out to everyone in your address book. Would you like it to be possible for that virus to automatically click the 'Allow' button?

The point is that this is a security dialog, and Microsoft have it protected against the sort of approach you outline (FindWindowEx, SetActiveWindow, SendMessage)

Amongst the possible alternatives are:
[ul]
[li]getting hold of a code signing PKI cert, telling Outlook to trust it, and then signing (Tools > Digital Signature in whatever Office VBA IDE you are using) your code with that cert[/li]

[li]using Extended MAPI which does not trigger the dialog. This is far from straightforward in vanilla VBA, but becomes pretty easy if you get hold of a Extended MAPI COM library such as Redemption. I've used this with great success in the past, but have to admit that was some years ago now[/li]

[li]hooking into the security dialog immediately it is created may allow you to bypass Microsoft's defensive programming. Have a look at my examples in thread222-662729. But be warned, I've never tested against Outlook security dialog, so cannot guarantee it will work.[/li]
[/ul]
 
Thank you, strongm, for your timely response! I truly appreciate all the information you shared. While I understand the need for Microsoft Outlook to protect against someone sending emails out to everyone in an address book, that scenario is very far from what I was attempting to accomplish.

Yes, according to the heading of my post, it seemed to me that the “solution” was to automate clicking on the “Allow” button in the popup window. And I can see how that “solution” would potentially open an entire can of worms.....

But if we take a step back, the “real” issue becomes one of pasting an image into an email message without generating a security warning.

My environment is a corporate workplace which has all of our applications on extreme lockdown. This leaves me with only Microsoft Outlook and VBA to work with, as is, out of the box.

And, toward that end, I’ve managed to find a workable solution with the help of a posting by Ron de Bruin.

Allow me to rename the title to my post: Using VBA to automate pasting an image into a Microsoft email message without raising a security alert.

The attached file has the working code:
 
 https://files.engineering.com/getfile.aspx?folder=43753f1a-d94e-48a9-9268-fb003d9990a1&file=404_APPLY_Update.txt
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top