Hi,
I am using the below code to send a mail if there is any content present in the file. Now I need the code to check the multiple files and it has to send that file in a mail, if there is any content in that file. I am new to this macro code. can you pls help me?
Sub object_status_mismatch()
Open "E:\OBJECT_STATUS_MONITORING\object_status_mismatch_rpt.csv" For Input As #1
r = 0
Do Until EOF(1)
Line Input #1, Data
r = r + 1
Loop
Close #1
If (r > 0) Then
Const Outlookmailitem As Integer = 0
Set OutlookApp = CreateObject("Outlook.Application")
Set outlookmail = OutlookApp.createitem(Outlookmailitem)
outlookmail.to = Sheets("sheet1").Range("B1").Value
outlookmail.cc = Sheets("sheet1").Range("B2").Value
outlookmail.Subject = "WARNING: Object mismatch in database " & Format(Date, "DD-MMM-YY")
outlookmail.Body = "Hi, " & vbCrLf & "Pls find the attached object mismatch details " & vbCrLf & vbCrLf & "This is an automated mail"
attmnt = "E:\OBJECT_STATUS_MONITORING\object_status_mismatch_rpt.csv"
outlookmail.attachments.Add attmnt
outlookmail.Send
End If
'MsgBox r
End Sub
Bookmarks