I have an Outlook VBA program that sends Emails to a list of 500+ recipients contained in a spreadsheet. The program functions, but I notice something odd when the Emails are sent from a Hotmail account. The Emails don't get sent until the macro ends. It seems like they are suspended somewhere until the macro ends.
On the other hand, when I send from a GMail account, each Email is sent when the ".send" code is encountered. I call a delay routine (KillSomeTime) so that the sending server doesn't get overwhelmed and to reduce the chance that the Email's will get treated as spam. But that delay routine is meaningless when the ".SendUsingAccount" is the hotmail account, since they all process at once.
Here is a subset of the code that sends the Emails:
With objNewItem
.Display
'Store the selected sender into objNewItem.SendUsingAccount
.SendUsingAccount = objSelectedAccount
'Store the original body into the new item body.
'NOTE: HTMLBody preserves the rich text.
.HTMLBody = objOriginalItem.HTMLBody
.Subject = objOriginalItem.Subject
.To = strEmailAddress
'Loop through the attachments in objOriginalItem
'Save them to the user's temp folder.
'Attach them to objNewItem.
For Each objAtt In objOriginalItem.Attachments
strAttFile = strTempPath & objAtt
objAtt.SaveAsFile strAttFile
objNewItem.Attachments.Add strAttFile, , , objAtt.DisplayName
objFSO.DeleteFile strAttFile
Next
.Send
'Set and Start objSyncObject to execute "Send / Receive" for this item
Set objSyncObject = objSyncObjects(1)
objSyncObject.Start
'Call the log_event function
Call log_event(strSubject, strEmailAddress)
'Call the kill_some_time function
Call kill_some_time(lngPauseTime)
End With
Is there any way to make adjustments to the code so that it takes into account the cause for Hotmail's delay in executing the ".Send"?
You can try using the MailItem.DeferredDeliveryTime property which allows setting a Date indicating the date and time the mail message is to be delivered.