I have a routine in VB to email out but I have an issue with the email staying in the Outbox and not automatically being pushed. It will eventually send if I wait long enough if Outlook stays open or when I re-initialize it. (Since it is set to close Outlook, if it was not Open)
Is there a way to get this routine to give it a little nudge or kick to push it? This will resolve my problem. Also, I want to verify that the code is correct to check if there is an instance of Outlook open and if not - Open it, send mail and then close it. (But to empty the Outbox first)
All my end-users are using Office 2010 (Outlook & Excel)
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error GoTo 0
.To = "firstname.lastname@example.org"
.Subject = "MonthEnd Data"
Set oOutlook = Nothing
Set OutMail = Nothing
Set OutApp = Nothing