View Single Post
Old 08-12-2019, 07:10 AM
johnc83 johnc83 is offline Windows 7 64bit Office 2003
Join Date: Jul 2015
Posts: 5
johnc83 is on a distinguished road
Default Outlook 2013 - Sending email when closed

Hi, I have a task-scheduler spreadsheet with VBA that edits and the calls a wscript .vbs file. It all works smoothly right up until the Outbox.

If I have Outlook open at the time of the spreadsheet running, I get an error of this.

ActiveX component can't create object: 'Outlook.Application'
Code: 800A01AD

If I have Outlook closed at the time of the scheduled spreadsheet, then no error but the e-mail sits in the Outbox until Outlook is opened and then is sent almost immediately.

I could schedule Outlook to open and close throughout the day when these spreadsheets are running but I'd rather it just worked when Outlook is open all the time.

Here is the .vbs code
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
objMailItem.Recipients.Add ("")
objMailItem.Subject = "Midnight Tank Stock Report"
objMailItem.Body = "Here is my body"
Set objMailItem = nothing
Reply With Quote