Excel Macro Send Reminders one email only, but all the topics pending for the person

CheeseBurger5

New Member
Joined
Apr 18, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi, guys,

I need some help. I am trying to create a macro where the all pending tasks for one person, one e-mail, will be included in one outlook e-mail. Basically the program will search for the pending tasks, group them all and send it to the e-mail of the person it is assigned to.

I was able to modify/create a code where the pending task reminders are sent automatically, but it is sending one task per e-mail. Even if it is the same person, it will still create a separate e-mail. So... this kinda floods the person with different and multiple pending reminders hahahahaha! That's why I thought is it possible to have one e-mail reminder, and it includes all the pending tasks for that one person already? This way I will be able to send reminders, AND not flood the person with multiple pending tasks hahahaha! Here's what I have...

Sub Reminder()
Dim wStat As Range, i As Long
Dim dam As Object

For Each wStat In Range("D6", Range("D" & Rows.Count).End(xlUp))
If wStat.Value = "Pending" Then
i = wStat.Row
If Cells(i, "I").Value <= Range("I3").Value Then
Set dam = CreateObject("Outlook.Application").CreateItem(0)
dam.To = Range("L" & i).Value
dam.CC = Range("L" & i).Value
dam.Subject = Range("B" & i).Value
dam.Body = "Dear " & Range("E" & i).Value & "," & vbCr & vbCr & _
"This is to remind you that the task: " & Range("B" & wStat.Row).Value & " - " & " " & _
"is still pending." & vbCr & vbCr & _
"Thank you!"
'
dam.Send 'change send to display if you want to check
wStat.Value = "Pending"
End If
End If
Next
MsgBox "Reminders Sent!"
End Sub

1618802346315.png


The outlook looks like this now (Separate outlook window, same e-mail, different tasks)

1618802448886.png



I want it to look like this (One outlook window, same e-mail, different tasks included in that window)

1618802516349.png


Can anyone help please? Any help would be appreciated! Thank you!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

severynm

Active Member
Joined
Jan 8, 2021
Messages
261
Office Version
  1. 365
Platform
  1. Windows
Before you populate the body, you'll want to add an extra loop to go search over the table again for all open tasks for the current person. For each item in the list, if the name = current name of the loop and the status = pending then append the task name to a new variable. Something like:

VBA Code:
    Dim listOfTasks As String
    Dim idx As Integer
    For idx = 0 To Range("D" & Rows.count).End(xlUp)
        If SheetName.Range("C" & idx).Value = currentName And SheetName.Range("D" & idx).Value = "Pending" Then
            listOfTasks = listOfTasks & SheetName.Range("A" & idx).Value & vbCr
        End If
    Next idx

You'll need to create a variable in your outer loop to keep track of the name of the current person (who you'll send the email to). That can be used in place of currentName.

That way you can just use listOfTasks in the body of your email.
 

Forum statistics

Threads
1,148,256
Messages
5,745,698
Members
423,969
Latest member
CHHeights

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top