#1
|
|||
|
|||
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 Code:
Dim objOutl Set objOutl = CreateObject("Outlook.Application") Set objMailItem = objOutl.CreateItem(olMailItem) objMailItem.Recipients.Add ("john.smith@gmail.com") objMailItem.Display objMailItem.Subject = "Midnight Tank Stock Report" objMailItem.Body = "Here is my body" objMailItem.Send Set objMailItem = nothing |
#2
|
||||
|
||||
If you modify your code to call the function at Test if Outlook is open and open Outlook with VBA then Outlook should always be opened correctly regardless of whether it is running or not.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Hi, thanks for the reply. I've managed to sort now. It appears that running the scheduled task with the 'Higher' privileges* is effectively running it as Administrator. If I make sure Outlook is started as Administrator then the Excel spreadsheet can communicate fine with it.
*the reason I need higher privileges ticked is because if my RDP session locks (which it will do after 5 mins automatically) then the scheduled task just won't run |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Expanding "CC" field when sending an email in Outlook 2013 | Dougmeister | Outlook | 0 | 11-29-2017 06:57 AM |
Outlook not sending email | grjbyfleet | Outlook | 1 | 07-30-2016 11:52 AM |
outlook.com account in Outlook 2007 freezes at 93% sending/receiving email | ink8 | Outlook | 0 | 10-10-2012 12:19 PM |
Outlook not sending body of email | sbertram | Outlook | 0 | 08-30-2012 11:50 AM |
Receiving but not sending email in outlook? | babylikesburgh | Outlook | 2 | 12-05-2010 06:29 PM |