I have the following code, which works fine, except that the active workbook is not being attached to the outlook email created
Kindly amend my code
Kindly amend my code
Code:
Sub Email_Report()
ThisWorkbook.Activate 'start in THIS workbook
ztext = [bodytext] 'read in text from named cell
Zsubject = [subjectText]
Sheets("Summary Inventory").Select
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
With OutMail
.To = Range("T1:T1").Value
.CC = Join(Application.Transpose(Range("T2:T5").Value), ";")
.BCC = ""
.Subject = Zsubject
.Body = ztext
.Attachments.Add Destwb.FullName
'
.Display 'Use .send to send automatically or .Display to check email before sending
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Last edited: