The Workbook Hangs until .Send
function ends then procedures running have finished.
There is a procedure which contains below snip code, calling with another one.
.AddAttachment
below has about 5MB file passed to.
When the VBA code is running, it blocks the main thread, hence the freezing.
Some VBA functions (such as printing a Word document) have the option to be sent to a background process. (.PrintOut Background:=True
)
Is it possible to sent
.Send
function to a background to have the macro continue while CDO Mail sends with attached file?
The code snip is:
Dim iMsg As Object
Dim iConf As Object
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
With iMsg
Set .Configuration = iConf
.To = strTo
.ReplyTo = "Email Address"
.From = """Sender Name (Email Address)"" <EmailAddress>"
.Subject = strSubject
.TextBody = strBody
.AddAttachment ThisWorkbook.Path & "\Temp\" & ThisWorkbook.Name
.Send
End With