Reecenorman1996
New Member
- Joined
- Jul 20, 2023
- Messages
- 31
- Office Version
- 365
- Platform
- Windows
Below is the code i use i need a check to see if column i is greater than 5, if it is then send the email if not do not send the email
Sub Send_Bulk_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("sheet1")
Dim i As Integer
Dim OA As Object
Dim msg As Object
Set OA = CreateObject("outlook.application")
Dim last_row As Integer
last_row = Application.CountA(sh.Range("c:c"))
For i = 2 To last_row
Set msg = OA.createitem(0)
msg.to = sh.Range("i" & i).Value
msg.cc = sh.Range("j" & i).Value & ";" & sh.Range("k" & i).Value
msg.Subject = sh.Range("l" & i).Value
msg.Body = sh.Range("m" & i).Value
msg.send
sh.Range("n" & i).Value = "1"
Next i
MsgBox "All emails have been sent"
End Sub
Sub Send_Bulk_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("sheet1")
Dim i As Integer
Dim OA As Object
Dim msg As Object
Set OA = CreateObject("outlook.application")
Dim last_row As Integer
last_row = Application.CountA(sh.Range("c:c"))
For i = 2 To last_row
Set msg = OA.createitem(0)
msg.to = sh.Range("i" & i).Value
msg.cc = sh.Range("j" & i).Value & ";" & sh.Range("k" & i).Value
msg.Subject = sh.Range("l" & i).Value
msg.Body = sh.Range("m" & i).Value
msg.send
sh.Range("n" & i).Value = "1"
Next i
MsgBox "All emails have been sent"
End Sub