lost_in_the_sauce
Board Regular
- Joined
- Jan 18, 2021
- Messages
- 128
- Office Version
- 365
- Platform
- Windows
Large invoice tracking spreadsheet - trying to run a code that will send an email to each recipient in column C if there is a "Y" in column E, and attaching a pdf from a file path in G. I can update the subject line and body each month in the code before sending.
VBA Code:
Sub Sendmail_Attach
If Range(“E:E”).Value = Y Then
Dim EmailApp As Outlook.Application
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
.To = emailTo Cells(C:C).Value
..CC = ""
.BCC = ""
.Subject = "Invoice update request"
.Attachments.Add Range("G:G").Value
.Body = emailBody
'.Send
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next
End Sub