Dear all the VBA code is not working properly as it should send a reminder email if it checks there was "send Reminder" in the column to selected emails. The problem`s only working on row number one which contain " send "send Reminder" but another row no. Therefore I need your assistance in this issue
The Code should send a reminder for all the email ist to the right if there is a send reminder in the remark column . Moreover, the project description should be included in the email subject and email body automatically
here is the code which I have written but it`s only working for Row 1 but I need it to work for all the rows in the worksheet.
NO. | Project Description | Due Date l | Remarks | Email Address for the people who are responsible |
1 | Project 1 | 1/1/2020 | Send Reminder | email1@outlook.com |
2 | Project 2 | 1/4/2020 | email2@outlook.com | |
3 | Project 3 | 1/1/2020 | Send Reminder | email3@gmail.com |
4 | Project 4 | 1/1/2020 | Send Reminder | email4@hotmail.com |
The Code should send a reminder for all the email ist to the right if there is a send reminder in the remark column . Moreover, the project description should be included in the email subject and email body automatically
here is the code which I have written but it`s only working for Row 1 but I need it to work for all the rows in the worksheet.
VBA Code:
Sub SendReminderMail()
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim iCounter As Integer
Dim iCounter2 As Integer
Dim MailDest As String
Dim Subj As String
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
With OutLookMailItem
MailDest = ""
Subj = ""
For iCounter = 1 To WorksheetFunction.CountA(Columns(4))
If MailDest = "" And Cells(iCounter, 4).Offset(0, -1) = "Send Reminder" Then
MailDest = Cells(iCounter, 4).Value
ElseIf MailDest <> "" And Cells(iCounter, 4).Offset(0, -1) = "Send Reminder" Then
MailDest = MailDest & ";" & Cells(iCounter, 4).Value
End If
Next iCounter
For iCounter2 = 1 To WorksheetFunction.CountA(Columns(4))
If Subj = "" And Cells(iCounter2, 4).Offset(0, -1) = "Send Reminder" Then
Subj = Cells(iCounter2, 1).Value
End If
Next iCounter2
.BCC = MailDest
.Subject = Subj
.Body = "Reminder: Your next credit card payment is due. Please ignore if already paid." & Subj
.Send
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub
Last edited by a moderator: