Code to bypass Outlook's security prompt

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,300
Hello everyone - -



Situation

As most of you know, when sending an email in code from Excel through Outlook, the following Microsoft Office Outlook dialog appears during code execution in Office releases since 2002:

A Program is trying to automatically send e-mail on your behalf.
Do you want to allow this?
If this is unexpected, it may be a virus and you should choose "No".

Two buttons: [Yes] [No]



Question

Has anyone used or developed code that bypasses this prompt, and if so, would you please post an example of your code here. What I would like is a macro in VBA and / or API that you know from your own first-hand experience has worked for you, that emails an Excel attachment from Excel, using Outlook (not Outlook Express) as the email client, which bypasses the above prompt.



Disqualifiers

(1)
I am aware of but cannot use any commercial utility programs such as Redemption or "ClickYes" from ContextMagic. This project will need to run on systems not allowed to download such utilities.

(2)
I am aware of email-related sites such as Ron Debruin's and others. Respectfully, I do not want or need links to those sites. Taking nothing away from Ron or anyone else, I have visited dozens of sites and tested lots of code including my own, but have not found, modified, or been able to develop code that actually does what I am asking for.

(3)
I cannot use the CDO method. I will not know what my end user clients' SMTP server addresses will be.

(4)
The solution cannot involve C++ or other development languages. Only a stand-alone macro in an Excel workbook that uses VBA and / or API will suffice.

(5)
I cannot use an older Office pre-security prompt version. This project will need to be executed on Office 2003 applications.



Qualifiers

(1)
Early or late binding is OK.

(2)
Establishing any VBA Project library references would be no problem.

(3)
Must be VBA / API code for an Excel macro that sends an Email with an Excel attachment in Outlook which bypasses the Outlook security prompt.

(4)
The code you post has been tested successfully by you.



Many thanks to you VBA and API wizards out there who can help me develop this solution, if indeed a solution is possible given the disqualifiers.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,

Not sure how helpful I'll be, still learning VBA and all and I've not tried to send an email with a macro. However, perhaps if you set Application.DisplayAlerts = False, execute your code to send, then set Application.DisplayAlerts = True before you end your code, that will accomplish what you want? The Help file says it selects the default automatically for you, and I don't know which way it will swing, but perhaps it will work. Heck, if not, only two lines of code to waste time on right? :LOL:
 
Upvote 0
Thank you for pointing me in that direction Joe. I figured if the answer existed anywhere it would be on this site or developed by one of the regulars on this site.

With modifications, the link for the macro by MichaelRo was just what I was looking for. I tried send keys with other testing and nothing worked until that macro.

Thanks again, and I sent a message to MichaelRo to thank him as well for posting that a couple months ago, which I obviously missed in my search attempts.
 
Upvote 0
Hi Tom,
Its probably too late But I use this and it works.




Code:
Sub Send()

Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Set objmail = objol.createitem(olmailitem)
With objmail
.To = "Anybody@hotmail.com"
.cc = "SomebodyElse@hotmail.com"
.Subject = "TEST EMAIL"
.Body = "THIS IS THE BODY"
.NoAging = True
.Attachments.Add ("C:\A test.xls")
.display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True

End Sub
 
Upvote 0
Thanks FFF, this is very close to the code in the link; I appreciate you confirming your experience that it works for you too. Looks like this case is closed, thanks you guys.
 
Upvote 0
HELP!

I dont know what is happening with my code, but it always seems to get stuck on:
Dim objol As New Outlook.Application

Any ideas that would work for me?

Im wanting to send an email to all the people in Coloum A

Thanks,

Staffie007
 
Upvote 0
I dont think you have your Oulook Reference installed.

Go to: TOOLS_
MACROS_
VISUAL BASIC EDITOR_

Then go to

Tools_
References_

and look for :
Microsoft Outlook 10.00 Object Library

check it in the box.

Or if you have Excel 2003 its:


Microsoft Outlook 11.00 Object Library
 
Upvote 0

Forum statistics

Threads
1,215,328
Messages
6,124,299
Members
449,149
Latest member
mwdbActuary

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