Hi,
I would like to add a 'Check Names' object to my Code.
My code refers to a table, named 'Leavers' so that the users of the Macro File can update it with ease by adding/removing recipients without messing with the code.
I'm using Office 365.
Here is my code:
Thanks in advance!
I would like to add a 'Check Names' object to my Code.
My code refers to a table, named 'Leavers' so that the users of the Macro File can update it with ease by adding/removing recipients without messing with the code.
I'm using Office 365.
Here is my code:
VBA Code:
Sub Leavers()
Dim OutApp As Object, OutMail As Object
Dim emailTo As String, emailCC As String
Dim PrevMnthYear As Date
Dim c As Range
PrevMnthYear = Format(DateAdd("m", -1, Date), "mmmm yyyy")
emailTo = WorksheetFunction.TextJoin(";", True, ActiveSheet.Range("Leavers[To]"))
emailCC = WorksheetFunction.TextJoin(";", True, ActiveSheet.Range("Leavers[CC]"))
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = emailTo
.CC = emailCC
.Subject = Format(DateAdd("m", -1, Date), "mmmm yyyy") & " - Leavers Report"
.Body = "Dear colleagues," & vbCrLf & vbCrLf & _
"Please find attached a Leavers report for " & Format(DateAdd("m", -1, Date), "mmmm yyyy") & vbCrLf & vbCrLf & "Best wishes,"
'.Attachments.Add
OutMail.display
End With
End Sub
Thanks in advance!