I discovered this VBA code for Excel that automatically sends emails using the addresses in Column A, any CC addresses in Column B, the email body in Column C, and the filepath of any attachments in Column D.
While I don't require Column B to contain CC, I do require that the email be sent from a particular address that is shared with coworkers. (instead of using my default personal, like it does now)
Here is how the Excel SS looks so far with currently 2 examples
Below is the VBA code I currently have and it works perfectly so far:
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("Sheet1")
Set OutApp = CreateObject("Outlook.Application")
For Each cell In sh.Columns("A").Cells.SpecialCells(xlCellTypeConstants)
'Enter the path/file names in the D:Z column in each row
Set rng = sh.Cells(cell.Row, 1).Range("D1:Z1")
If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = sh.Cells(cell.Row, 1).Value
.cc = sh.Cells(cell.Row, 2).Value
.Subject = "Example Subject 1"
.Body = sh.Cells(cell.Row, 3).Value
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell.Value) <> "" Then
If Dir(FileCell.Value) <> "" Then
.Attachments.Add FileCell.Value
End If
End If
Next FileCell
.Send 'Or use .Display/Send
End With
Set OutMail = Nothing
End If
Next cell
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub