Loveexcelll
New Member
- Joined
- Feb 24, 2022
- Messages
- 4
- Office Version
- 365
- 2019
- 2016
Hello,
Can you please help with this VBA? what is want to change is the following:
I want to add new emails every time, but the problem is that the code sends or sees the old emails as new. I want to keep the sended emails as status "Send"
en add new emails to send in the future, so can you change the code to stop sending emails when the status is, "send" in colum F?
Can you please help with this VBA? what is want to change is the following:
I want to add new emails every time, but the problem is that the code sends or sees the old emails as new. I want to keep the sended emails as status "Send"
en add new emails to send in the future, so can you change the code to stop sending emails when the status is, "send" in colum F?
VBA Code:
Sub Send_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Send_Mails")
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("A:A"))
For i = 2 To last_row
Set msg = OA.createitem(0)
msg.to = sh.Range("A" & i).Value
msg.cc = sh.Range("B" & i).Value
msg.Subject = sh.Range("C" & i).Value
msg.body = sh.Range("D" & i).Value
If sh.Range("E" & i).Value <> "" Then
msg.attachments.Add sh.Range("E" & i).Value
End If
msg.send
sh.Range("F" & i).Value = "[COLOR=rgb(226, 80, 65)]Sent[/COLOR]"
Next i
MsgBox "All the mails have been sent successfully"
End Sub