bumbum2812
New Member
- Joined
- Sep 7, 2020
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
Hi Experts
Please help me to modify below code to take all PDF file contain specific word like "ReportA", "ReportB"
j 2 to 3 is my third column with exact file name & file extension.
Please help me to modify below code to take all PDF file contain specific word like "ReportA", "ReportB"
j 2 to 3 is my third column with exact file name & file extension.
VBA Code:
Sub send_email_complete()
Dim outlookApp As Object
Dim myMail As Object
Dim source_file, to_emails, cc_emails As String
Dim i, j As Integer
Dim An As String
Dim folderPath As String
folderPath = Application.ActiveWorkbook.Path
An = Application.UserName
Set outlookApp = CreateObject("Outlook.Application")
Set myMail = outlookApp.CreateItem(0)
With myMail
For i = 2 To 2
to_emails = to_emails & Cells(i, 1) & ";"
cc_emails = cc_emails & Cells(i, 2) & ";"
Next i
For j = 2 To 3
source_file = folderPath & "\" & Cells(j, 3)
.Attachments.Add source_file
Next
ThisWorkbook.Save
source_file = ThisWorkbook.FullName
.Attachments.Add source_file
.CC = cc_emails
.To = to_emails
.Subject = "Files for Everyone"
.Body = "Hi Everyone," & vbNewLine & "Please read these before the meeting." & vbNewLine & "Thanks"
.Display
End With
End Sub