sharkey
New Member
Good evening all,
I'm working on a file that automatically sends two files to multiple To: recipients, based off of emails in column I, I'd like to also CC: the emails in columns J and K (because those will vary depending on the recipient) but I have no idea how to do that. Any help would be greatly appreciated!
The code is below and I've included my working file, I'm sure it's an easy solution and I'm probably just inept.
Thanks in advance!
I'm working on a file that automatically sends two files to multiple To: recipients, based off of emails in column I, I'd like to also CC: the emails in columns J and K (because those will vary depending on the recipient) but I have no idea how to do that. Any help would be greatly appreciated!
The code is below and I've included my working file, I'm sure it's an easy solution and I'm probably just inept.
Thanks in advance!
Code:
Sub Send_Files()
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim cell As Range
Dim FileCell As Range
Dim rng As Range
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets("Distribution List")
Set OutApp = CreateObject("Outlook.Application")
For Each cell In sh.Columns("I").Cells.SpecialCells(xlCellTypeConstants)
Set rng = sh.Cells(cell.Row, 1).Range("L1:M1")
If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
strbody = Range("C5")
strsigned = Range("C6")
With OutMail
.To = cell.Value
.CC = ThisWorkbook.Sheets("Distribution List").Range("J1").Value
.Subject = "Renewals Data"
.Body = Cells(cell.Row, "F").Value & "," & vbNewLine & vbNewLine & strbody & vbNewLine & vbNewLine & "Thanks," & vbNewLine & strsigned
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell) <> "" Then
If Dir(FileCell.Value) <> "" Then
.Attachments.Add FileCell.Value
End If
End If
Next FileCell
.Send
End With
Set OutMail = Nothing
End If
Next cell
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub