Automate sending Outlook emails from Excel VBA

Roland Hoelscher

New Member
Joined
Oct 15, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I want to develop an Excel VBA which sends emails using MS Outlook. I basically have a prototype that works (using early binding, I added the reference to MS Outlook, using GetObject, etc.)
When I run the VBA I get a warning message from Outlook which says "A program is trying to send an email message on your behalf . . ." Is there any way to eliminate that warning without changing the Outlook Trust Center settings? In my corporate environment I don't have permissions to change the corresponding Trust Center setting. If my Excel VBA solution needs to send hundreds of emails each time I run the VBA, then clicking on "Allow" in the Outlook warning message is not a feasible solution. Any way I can eliminate or bypass that Outlook warning?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Can you describe what your Excel VBA does? I think one solution would be to port the macro to Outlook. Then Outlook can read the data from an Excel file and Outlook will be doing the sending, which should avoid the warning. This should be fairly straightforward if you are using early binding.
 
Upvote 0
Thank you Jeff for looking at this. Attached are the code I created for sending two emails and the warning I get from Outlook for each email. Its just a simple test of driving Outlook from Excel. I have strong Excel VBA skills, but Outlook integration is new to me.
1665882990860.png


1665883056042.png
 
Upvote 0
Can you please go to the VBA window, Copy the code then Paste it directly into a post? Then select the code and click the VBA button to preserve formatting. Otherwise I would have to eyeball it and type it all in, which I'm not going to do. Thanks,

You have hardcode what cells have recipient and body. How is this going to work in the real thing? What is the file name of your Excel file? What worksheet contains the data?
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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